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

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

[Source]

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

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

[Source]

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

Oracle requires recursive CTEs to have column aliases.

[Source]

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

Oracle requires SQL standard datetimes

[Source]

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

Handle LIMIT by using a unlimited subselect filtered with ROWNUM.

[Source]

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

Oracle supports GROUP BY CUBE

[Source]

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

Oracle supports GROUP BY ROLLUP

[Source]

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

Oracle does not support INTERSECT ALL or EXCEPT ALL

[Source]

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

Oracle does not support IS TRUE.

[Source]

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

Oracle does not support SELECT *, column

[Source]

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

Oracle supports timezones in literal timestamps.

[Source]

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

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

[Source]

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

Oracle supports window functions

[Source]

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

[Validate]