Oracle needs to emulate bitwise operators and ILIKE/NOT ILIKE operators.
# File lib/sequel/adapters/shared/oracle.rb, line 209 209: def complex_expression_sql_append(sql, op, args) 210: case op 211: when :& 212: sql << complex_expression_arg_pairs(args){|a, b| "CAST(BITAND(#{literal(a)}, #{literal(b)}) AS INTEGER)"} 213: when :| 214: sql << complex_expression_arg_pairs(args){|a, b| "(#{literal(a)} - #{complex_expression_sql(:&, [a, b])} + #{literal(b)})"} 215: when :^ 216: sql << complex_expression_arg_pairs(args){|*x| "(#{complex_expression_sql(:|, x)} - #{complex_expression_sql(:&, x)})"} 217: when :'B~' 218: sql << BITCOMP_OPEN 219: literal_append(sql, args.at(0)) 220: sql << BITCOMP_CLOSE 221: when :<< 222: sql << complex_expression_arg_pairs(args){|a, b| "(#{literal(a)} * power(2, #{literal b}))"} 223: when :>> 224: sql << complex_expression_arg_pairs(args){|a, b| "(#{literal(a)} / power(2, #{literal b}))"} 225: when :% 226: sql << complex_expression_arg_pairs(args){|a, b| "MOD(#{literal(a)}, #{literal(b)})"} 227: when :ILIKE, :'NOT ILIKE' 228: sql << ILIKE_0 229: literal_append(sql, args.at(0)) 230: sql << ILIKE_1 231: sql << (op == :ILIKE ? LIKE : NOT_LIKE) 232: sql<< ILIKE_2 233: literal_append(sql, args.at(1)) 234: sql << ILIKE_3 235: else 236: super 237: end 238: 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, line 243 243: def constant_sql_append(sql, c) 244: if c == :CURRENT_TIME 245: super(sql, :CURRENT_TIMESTAMP) 246: else 247: super 248: end 249: end
Use a custom expression with EXISTS to determine whether a dataset is empty.
# File lib/sequel/adapters/shared/oracle.rb, line 260 260: def empty? 261: db[:dual].where(@opts[:offset] ? exists : unordered.exists).get(1) == nil 262: end
Oracle uses MINUS instead of EXCEPT, and doesn’t support EXCEPT ALL
# File lib/sequel/adapters/shared/oracle.rb, line 252 252: def except(dataset, opts={}) 253: opts = {:all=>opts} unless opts.is_a?(Hash) 254: raise(Sequel::Error, "EXCEPT ALL not supported") if opts[:all] 255: compound_clone(:minus, dataset, opts) 256: end
Oracle requires recursive CTEs to have column aliases.
# File lib/sequel/adapters/shared/oracle.rb, line 292 292: def recursive_cte_requires_column_aliases? 293: true 294: end
Handle LIMIT by using a unlimited subselect filtered with ROWNUM.
# File lib/sequel/adapters/shared/oracle.rb, line 277 277: def select_sql 278: if (limit = @opts[:limit]) && !@opts[:sql] 279: ds = clone(:limit=>nil) 280: # Lock doesn't work in subselects, so don't use a subselect when locking. 281: # Don't use a subselect if custom SQL is used, as it breaks somethings. 282: ds = ds.from_self unless @opts[:lock] 283: sql = @opts[:append_sql] || '' 284: subselect_sql_append(sql, ds.where(SQL::ComplexExpression.new(:<=, ROW_NUMBER_EXPRESSION, limit))) 285: sql 286: else 287: super 288: end 289: 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, line 272 272: def sequence(s) 273: clone(:sequence=>s) 274: end
Oracle supports GROUP BY CUBE
# File lib/sequel/adapters/shared/oracle.rb, line 297 297: def supports_group_cube? 298: true 299: end
Oracle supports GROUP BY ROLLUP
# File lib/sequel/adapters/shared/oracle.rb, line 302 302: def supports_group_rollup? 303: true 304: end
Oracle does not support INTERSECT ALL or EXCEPT ALL
# File lib/sequel/adapters/shared/oracle.rb, line 307 307: def supports_intersect_except_all? 308: false 309: end
Oracle does not support IS TRUE.
# File lib/sequel/adapters/shared/oracle.rb, line 312 312: def supports_is_true? 313: false 314: end
Oracle does not support SELECT *, column
# File lib/sequel/adapters/shared/oracle.rb, line 317 317: def supports_select_all_and_column? 318: false 319: end
Oracle supports timezones in literal timestamps.
# File lib/sequel/adapters/shared/oracle.rb, line 322 322: def supports_timestamp_timezones? 323: true 324: end
Oracle does not support WHERE ‘Y’ for WHERE TRUE.
# File lib/sequel/adapters/shared/oracle.rb, line 327 327: def supports_where_true? 328: false 329: end
Oracle supports window functions
# File lib/sequel/adapters/shared/oracle.rb, line 332 332: def supports_window_functions? 333: true 334: end
Oracle doesn’t support the use of AS when aliasing a dataset. It doesn’t require the use of AS anywhere, so this disables it in all cases.
# File lib/sequel/adapters/shared/oracle.rb, line 340 340: def as_sql_append(sql, aliaz) 341: sql << SPACE 342: quote_identifier_append(sql, aliaz) 343: end
The strftime format to use when literalizing the time.
# File lib/sequel/adapters/shared/oracle.rb, line 346 346: def default_timestamp_format 347: TIMESTAMP_FORMAT 348: end
If this dataset is associated with a sequence, return the most recently inserted sequence value.
# File lib/sequel/adapters/shared/oracle.rb, line 352 352: def execute_insert(sql, opts={}) 353: f = @opts[:from] 354: super(sql, {:table=>(f.first if f), :sequence=>@opts[:sequence]}.merge(opts)) 355: end
Use a colon for the timestamp offset, since Oracle appears to require it.
# File lib/sequel/adapters/shared/oracle.rb, line 358 358: def format_timestamp_offset(hour, minute) 359: sprintf(TIMESTAMP_OFFSET_FORMAT, hour, minute) 360: end
Oracle doesn’t support empty values when inserting.
# File lib/sequel/adapters/shared/oracle.rb, line 363 363: def insert_supports_empty_values? 364: false 365: end
Use string in hex format for blob data.
# File lib/sequel/adapters/shared/oracle.rb, line 368 368: def literal_blob_append(sql, v) 369: sql << APOS << v.unpack(HSTAR).first << APOS 370: end
Oracle uses ‘N’ for false values.
# File lib/sequel/adapters/shared/oracle.rb, line 373 373: def literal_false 374: BOOL_FALSE 375: end
Oracle uses ‘Y’ for true values.
# File lib/sequel/adapters/shared/oracle.rb, line 383 383: def literal_true 384: BOOL_TRUE 385: end
Use the Oracle-specific SQL clauses (no limit, since it is emulated).
# File lib/sequel/adapters/shared/oracle.rb, line 388 388: def select_clause_methods 389: SELECT_CLAUSE_METHODS 390: end
Modify the SQL to add the list of tables to select FROM Oracle doesn’t support select without FROM clause so add the dummy DUAL table if the dataset doesn’t select from a table.
# File lib/sequel/adapters/shared/oracle.rb, line 396 396: def select_from_sql(sql) 397: sql << FROM 398: source_list_append(sql, @opts[:from] || DUAL) 399: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.