Module Sequel::DB2::DatasetMethods
In: lib/sequel/adapters/shared/db2.rb

Methods

Included Modules

EmulateOffsetWithRowNumber

Constants

PAREN_CLOSE = Dataset::PAREN_CLOSE
PAREN_OPEN = Dataset::PAREN_OPEN
BITWISE_METHOD_MAP = {:& =>:BITAND, :| => :BITOR, :^ => :BITXOR, :'B~'=>:BITNOT}
BOOL_TRUE = '1'.freeze
BOOL_FALSE = '0'.freeze
CAST_STRING_OPEN = "RTRIM(CHAR(".freeze
CAST_STRING_CLOSE = "))".freeze
FETCH_FIRST_ROW_ONLY = " FETCH FIRST ROW ONLY".freeze
FETCH_FIRST = " FETCH FIRST ".freeze
ROWS_ONLY = " ROWS ONLY".freeze
EMPTY_FROM_TABLE = ' FROM "SYSIBM"."SYSDUMMY1"'.freeze

Public Instance methods

DB2 casts strings using RTRIM and CHAR instead of VARCHAR.

[Source]

     # File lib/sequel/adapters/shared/db2.rb, line 210
210:       def cast_sql_append(sql, expr, type)
211:         if(type == String)
212:           sql << CAST_STRING_OPEN
213:           literal_append(sql, expr)
214:           sql << CAST_STRING_CLOSE
215:         else
216:           super
217:         end
218:       end

Handle DB2 specific LIKE and bitwise operator support, and emulate the extract method, which DB2 doesn‘t natively support.

[Source]

     # File lib/sequel/adapters/shared/db2.rb, line 222
222:       def complex_expression_sql_append(sql, op, args)
223:         case op
224:         when :ILIKE
225:           super(sql, :LIKE, [SQL::Function.new(:upper, args.at(0)), SQL::Function.new(:upper, args.at(1)) ])
226:         when "NOT ILIKE""NOT ILIKE"
227:           super(sql, "NOT LIKE""NOT LIKE", [SQL::Function.new(:upper, args.at(0)), SQL::Function.new(:upper, args.at(1)) ])
228:         when :&, :|, :^
229:           # works with db2 v9.5 and after
230:           op = BITWISE_METHOD_MAP[op]
231:           sql << complex_expression_arg_pairs(args){|a, b| literal(SQL::Function.new(op, a, b))}
232:         when :<<
233:           sql << complex_expression_arg_pairs(args){|a, b| "(#{literal(a)} * POWER(2, #{literal(b)}))"}
234:         when :>>
235:           sql << complex_expression_arg_pairs(args){|a, b| "(#{literal(a)} / POWER(2, #{literal(b)}))"}
236:         when :%
237:           sql << complex_expression_arg_pairs(args){|a, b| "MOD(#{literal(a)}, #{literal(b)})"}
238:         when 'B~''B~'
239:           literal_append(sql, SQL::Function.new(:BITNOT, *args))
240:         when :extract
241:           sql << args.at(0).to_s
242:           sql << PAREN_OPEN
243:           literal_append(sql, args.at(1))
244:           sql << PAREN_CLOSE
245:         else
246:           super
247:         end
248:       end

DB2 supports GROUP BY CUBE

[Source]

     # File lib/sequel/adapters/shared/db2.rb, line 251
251:       def supports_group_cube?
252:         true
253:       end

DB2 supports GROUP BY ROLLUP

[Source]

     # File lib/sequel/adapters/shared/db2.rb, line 256
256:       def supports_group_rollup?
257:         true
258:       end

DB2 does not support IS TRUE.

[Source]

     # File lib/sequel/adapters/shared/db2.rb, line 261
261:       def supports_is_true?
262:         false
263:       end

DB2 does not support multiple columns in IN.

[Source]

     # File lib/sequel/adapters/shared/db2.rb, line 266
266:       def supports_multiple_column_in?
267:         false
268:       end

DB2 only allows * in SELECT if it is the only thing being selected.

[Source]

     # File lib/sequel/adapters/shared/db2.rb, line 271
271:       def supports_select_all_and_column?
272:         false
273:       end

DB2 does not support fractional seconds in timestamps.

[Source]

     # File lib/sequel/adapters/shared/db2.rb, line 276
276:       def supports_timestamp_usecs?
277:         false
278:       end

DB2 does not support WHERE 1.

[Source]

     # File lib/sequel/adapters/shared/db2.rb, line 286
286:       def supports_where_true?
287:         false
288:       end

DB2 supports window functions

[Source]

     # File lib/sequel/adapters/shared/db2.rb, line 281
281:       def supports_window_functions?
282:         true
283:       end

[Validate]