Methods
Public Instance
- complex_expression_sql_append
- constant_sql_append
- empty?
- except
- recursive_cte_requires_column_aliases?
- requires_sql_standard_datetimes?
- select_sql
- sequence
- server_version
- supports_cte?
- supports_derived_column_lists?
- supports_fetch_next_rows?
- supports_group_cube?
- supports_group_rollup?
- supports_grouping_sets?
- supports_intersect_except_all?
- supports_is_true?
- supports_limits_in_correlated_subqueries?
- supports_merge?
- supports_nowait?
- supports_offsets_in_correlated_subqueries?
- supports_regexp?
- supports_select_all_and_column?
- supports_skip_locked?
- supports_timestamp_timezones?
- supports_where_true?
- supports_window_functions?
Included modules
- AutoCastDateAndTime
Constants
BITAND_PROC | = | lambda{|a, b| Sequel.lit(["CAST(BITAND(", ", ", ") AS INTEGER)"], a, b)} | ||
ROW_NUMBER_EXPRESSION | = | LiteralString.new('ROWNUM').freeze |
Public Instance methods
# File lib/sequel/adapters/shared/oracle.rb 339 def complex_expression_sql_append(sql, op, args) 340 case op 341 when :& 342 complex_expression_arg_pairs_append(sql, args, &BITAND_PROC) 343 when :| 344 complex_expression_arg_pairs_append(sql, args){|a, b| Sequel.lit(["(", " - ", " + ", ")"], a, complex_expression_arg_pairs([a, b], &BITAND_PROC), b)} 345 when :^ 346 complex_expression_arg_pairs_append(sql, args) do |*x| 347 s1 = complex_expression_arg_pairs(x){|a, b| Sequel.lit(["(", " - ", " + ", ")"], a, complex_expression_arg_pairs([a, b], &BITAND_PROC), b)} 348 s2 = complex_expression_arg_pairs(x, &BITAND_PROC) 349 Sequel.lit(["(", " - ", ")"], s1, s2) 350 end 351 when :~, :'!~', :'~*', :'!~*' 352 raise InvalidOperation, "Pattern matching via regular expressions is not supported in this Oracle version" unless supports_regexp? 353 if op == :'!~' || op == :'!~*' 354 sql << 'NOT ' 355 end 356 sql << 'REGEXP_LIKE(' 357 literal_append(sql, args[0]) 358 sql << ',' 359 literal_append(sql, args[1]) 360 if op == :'~*' || op == :'!~*' 361 sql << ", 'i'" 362 end 363 sql << ')' 364 when :%, :<<, :>>, :'B~' 365 complex_expression_emulate_append(sql, op, args) 366 else 367 super 368 end 369 end
Oracle
doesn’t support CURRENT_TIME, as it doesn’t have a type for storing just time values without a date, so use CURRENT_TIMESTAMP in its place.
# File lib/sequel/adapters/shared/oracle.rb 374 def constant_sql_append(sql, c) 375 if c == :CURRENT_TIME 376 super(sql, :CURRENT_TIMESTAMP) 377 else 378 super 379 end 380 end
Use a custom expression with EXISTS to determine whether a dataset is empty.
# File lib/sequel/adapters/shared/oracle.rb 390 def empty? 391 if @opts[:sql] 392 naked.each{return false} 393 true 394 else 395 db[:dual].where(@opts[:offset] ? exists : unordered.exists).get(1) == nil 396 end 397 end
Oracle
uses MINUS instead of EXCEPT, and doesn’t support EXCEPT ALL
# File lib/sequel/adapters/shared/oracle.rb 383 def except(dataset, opts=OPTS) 384 raise(Sequel::Error, "EXCEPT ALL not supported") if opts[:all] 385 compound_clone(:minus, dataset, opts) 386 end
Oracle
requires recursive CTEs to have column aliases.
# File lib/sequel/adapters/shared/oracle.rb 447 def recursive_cte_requires_column_aliases? 448 true 449 end
Oracle
requires SQL standard datetimes
# File lib/sequel/adapters/shared/oracle.rb 400 def requires_sql_standard_datetimes? 401 true 402 end
Handle LIMIT by using a unlimited subselect filtered with ROWNUM, unless Oracle
12 is used.
# File lib/sequel/adapters/shared/oracle.rb 413 def select_sql 414 return super if @opts[:sql] 415 return super if supports_fetch_next_rows? 416 417 o = @opts[:offset] 418 if o && o != 0 419 columns = clone(:append_sql=>String.new, :placeholder_literal_null=>true).columns 420 dsa1 = dataset_alias(1) 421 rn = row_number_column 422 limit = @opts[:limit] 423 ds = unlimited. 424 from_self(:alias=>dsa1). 425 select_append(ROW_NUMBER_EXPRESSION.as(rn)). 426 from_self(:alias=>dsa1). 427 select(*columns). 428 where(SQL::Identifier.new(rn) > o) 429 ds = ds.where(SQL::Identifier.new(rn) <= Sequel.+(o, limit)) if limit 430 sql = @opts[:append_sql] || String.new 431 subselect_sql_append(sql, ds) 432 sql 433 elsif limit = @opts[:limit] 434 ds = unlimited 435 # Lock doesn't work in subselects, so don't use a subselect when locking. 436 # Don't use a subselect if custom SQL is used, as it breaks somethings. 437 ds = ds.from_self unless @opts[:lock] 438 sql = @opts[:append_sql] || String.new 439 subselect_sql_append(sql, ds.where(SQL::ComplexExpression.new(:<=, ROW_NUMBER_EXPRESSION, limit))) 440 sql 441 else 442 super 443 end 444 end
Create a copy of this dataset associated to the given sequence name, which will be used when calling insert to find the most recently inserted value for the sequence.
# File lib/sequel/adapters/shared/oracle.rb 407 def sequence(s) 408 clone(:sequence=>s) 409 end
The version of the database server
# File lib/sequel/adapters/shared/oracle.rb 537 def server_version 538 db.server_version(@opts[:server]) 539 end
# File lib/sequel/adapters/shared/oracle.rb 451 def supports_cte?(type=:select) 452 type == :select 453 end
Oracle
does not support derived column lists
# File lib/sequel/adapters/shared/oracle.rb 456 def supports_derived_column_lists? 457 false 458 end
Oracle
supports FETCH NEXT ROWS since 12c, but it doesn’t work when locking or when skipping locked rows.
# File lib/sequel/adapters/shared/oracle.rb 462 def supports_fetch_next_rows? 463 server_version >= 12000000 && !(@opts[:lock] || @opts[:skip_locked]) 464 end
Oracle
supports GROUP BY CUBE
# File lib/sequel/adapters/shared/oracle.rb 467 def supports_group_cube? 468 true 469 end
Oracle
supports GROUP BY ROLLUP
# File lib/sequel/adapters/shared/oracle.rb 472 def supports_group_rollup? 473 true 474 end
Oracle
supports GROUPING SETS
# File lib/sequel/adapters/shared/oracle.rb 477 def supports_grouping_sets? 478 true 479 end
Oracle
does not support INTERSECT ALL or EXCEPT ALL
# File lib/sequel/adapters/shared/oracle.rb 482 def supports_intersect_except_all? 483 false 484 end
Oracle
does not support IS TRUE.
# File lib/sequel/adapters/shared/oracle.rb 487 def supports_is_true? 488 false 489 end
Oracle
supports MERGE
# File lib/sequel/adapters/shared/oracle.rb 497 def supports_merge? 498 true 499 end
Oracle
supports NOWAIT.
# File lib/sequel/adapters/shared/oracle.rb 502 def supports_nowait? 503 true 504 end
Oracle
10+ supports pattern matching via regular expressions
# File lib/sequel/adapters/shared/oracle.rb 542 def supports_regexp? 543 server_version >= 10010002 544 end
Oracle
does not support SELECT *, column
# File lib/sequel/adapters/shared/oracle.rb 512 def supports_select_all_and_column? 513 false 514 end
Oracle
supports SKIP LOCKED.
# File lib/sequel/adapters/shared/oracle.rb 517 def supports_skip_locked? 518 true 519 end
Oracle
supports timezones in literal timestamps.
# File lib/sequel/adapters/shared/oracle.rb 522 def supports_timestamp_timezones? 523 true 524 end
Oracle
does not support WHERE ‘Y’ for WHERE TRUE.
# File lib/sequel/adapters/shared/oracle.rb 527 def supports_where_true? 528 false 529 end
Oracle
supports window functions
# File lib/sequel/adapters/shared/oracle.rb 532 def supports_window_functions? 533 true 534 end