Module Sequel::Oracle::DatasetMethods
In: lib/sequel/adapters/shared/oracle.rb

Methods

Included Modules

EmulateOffsetWithRowNumber

Constants

SELECT_CLAUSE_METHODS = Dataset.clause_methods(:select, %w'with select distinct columns from join where group having compounds order lock')
ROW_NUMBER_EXPRESSION = 'ROWNUM'.lit.freeze
SPACE = Dataset::SPACE
APOS = Dataset::APOS
APOS_RE = Dataset::APOS_RE
DOUBLE_APOS = Dataset::DOUBLE_APOS
FROM = Dataset::FROM
BITCOMP_OPEN = "((0 - ".freeze
BITCOMP_CLOSE = ") - 1)".freeze
ILIKE_0 = "(UPPER(".freeze
ILIKE_1 = ") ".freeze
ILIKE_2 = ' UPPER('.freeze
ILIKE_3 = "))".freeze
LIKE = 'LIKE'.freeze
NOT_LIKE = 'NOT LIKE'.freeze
TIMESTAMP_FORMAT = "TIMESTAMP '%Y-%m-%d %H:%M:%S%N %z'".freeze
TIMESTAMP_OFFSET_FORMAT = "%+03i:%02i".freeze
BOOL_FALSE = "'N'".freeze
BOOL_TRUE = "'Y'".freeze
HSTAR = "H*".freeze
DUAL = ['DUAL'.freeze].freeze

Public Instance methods

Oracle needs to emulate bitwise operators and ILIKE/NOT ILIKE operators.

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 205
205:       def complex_expression_sql_append(sql, op, args)
206:         case op
207:         when :&
208:           sql << complex_expression_arg_pairs(args){|a, b| "CAST(BITAND(#{literal(a)}, #{literal(b)}) AS INTEGER)"}
209:         when :|
210:           sql << complex_expression_arg_pairs(args){|a, b| "(#{literal(a)} - #{complex_expression_sql(:&, [a, b])} + #{literal(b)})"}
211:         when :^
212:           sql << complex_expression_arg_pairs(args){|*x| "(#{complex_expression_sql(:|, x)} - #{complex_expression_sql(:&, x)})"}
213:         when 'B~''B~'
214:           sql << BITCOMP_OPEN
215:           literal_append(sql, args.at(0))
216:           sql << BITCOMP_CLOSE
217:         when :<<
218:           sql << complex_expression_arg_pairs(args){|a, b| "(#{literal(a)} * power(2, #{literal b}))"}
219:         when :>>
220:           sql << complex_expression_arg_pairs(args){|a, b| "(#{literal(a)} / power(2, #{literal b}))"}
221:         when :ILIKE, 'NOT ILIKE''NOT ILIKE'
222:           sql << ILIKE_0
223:           literal_append(sql, args.at(0))
224:           sql << ILIKE_1
225:           sql << (op == :ILIKE ? LIKE : NOT_LIKE)
226:           sql<< ILIKE_2
227:           literal_append(sql, args.at(1))
228:           sql << ILIKE_3
229:         else
230:           super
231:         end
232:       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.

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 237
237:       def constant_sql_append(sql, c)
238:         if c == :CURRENT_TIME
239:           super(sql, :CURRENT_TIMESTAMP)
240:         else
241:           super
242:         end
243:       end

Use a custom expression with EXISTS to determine whether a dataset is empty.

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 254
254:       def empty?
255:         db[:dual].where(@opts[:offset] ? exists : unordered.exists).get(1) == nil
256:       end

Oracle uses MINUS instead of EXCEPT, and doesn‘t support EXCEPT ALL

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 246
246:       def except(dataset, opts={})
247:         opts = {:all=>opts} unless opts.is_a?(Hash)
248:         raise(Sequel::Error, "EXCEPT ALL not supported") if opts[:all]
249:         compound_clone(:minus, dataset, opts)
250:       end

Oracle requires recursive CTEs to have column aliases.

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 286
286:       def recursive_cte_requires_column_aliases?
287:         true
288:       end

Oracle requires SQL standard datetimes

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 259
259:       def requires_sql_standard_datetimes?
260:         true
261:       end

Handle LIMIT by using a unlimited subselect filtered with ROWNUM.

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 271
271:       def select_sql
272:         if (limit = @opts[:limit]) && !@opts[:sql]
273:           ds = clone(:limit=>nil)
274:           # Lock doesn't work in subselects, so don't use a subselect when locking.
275:           # Don't use a subselect if custom SQL is used, as it breaks somethings.
276:           ds = ds.from_self unless @opts[:lock]
277:           sql = @opts[:append_sql] || ''
278:           subselect_sql_append(sql, ds.where(SQL::ComplexExpression.new(:<=, ROW_NUMBER_EXPRESSION, limit)))
279:           sql
280:         else
281:           super
282:         end
283:       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.

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 266
266:       def sequence(s)
267:         clone(:sequence=>s)
268:       end

Oracle supports GROUP BY CUBE

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 291
291:       def supports_group_cube?
292:         true
293:       end

Oracle supports GROUP BY ROLLUP

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 296
296:       def supports_group_rollup?
297:         true
298:       end

Oracle does not support INTERSECT ALL or EXCEPT ALL

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 301
301:       def supports_intersect_except_all?
302:         false
303:       end

Oracle does not support IS TRUE.

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 306
306:       def supports_is_true?
307:         false
308:       end

Oracle does not support SELECT *, column

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 311
311:       def supports_select_all_and_column?
312:         false
313:       end

Oracle supports timezones in literal timestamps.

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 316
316:       def supports_timestamp_timezones?
317:         true
318:       end

Oracle does not support WHERE ‘Y’ for WHERE TRUE.

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 321
321:       def supports_where_true?
322:         false
323:       end

Oracle supports window functions

[Source]

     # File lib/sequel/adapters/shared/oracle.rb, line 326
326:       def supports_window_functions?
327:         true
328:       end

[Validate]