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 191
191:       def cast_sql_append(sql, expr, type)
192:         if(type == String)
193:           sql << CAST_STRING_OPEN
194:           literal_append(sql, expr)
195:           sql << CAST_STRING_CLOSE
196:         else
197:           super
198:         end
199:       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 203
203:       def complex_expression_sql_append(sql, op, args)
204:         case op
205:         when :ILIKE
206:           super(sql, :LIKE, [SQL::Function.new(:upper, args.at(0)), SQL::Function.new(:upper, args.at(1)) ])
207:         when "NOT ILIKE""NOT ILIKE"
208:           super(sql, "NOT LIKE""NOT LIKE", [SQL::Function.new(:upper, args.at(0)), SQL::Function.new(:upper, args.at(1)) ])
209:         when :&, :|, :^
210:           # works with db2 v9.5 and after
211:           op = BITWISE_METHOD_MAP[op]
212:           sql << complex_expression_arg_pairs(args){|a, b| literal(SQL::Function.new(op, a, b))}
213:         when :<<
214:           sql << complex_expression_arg_pairs(args){|a, b| "(#{literal(a)} * POWER(2, #{literal(b)}))"}
215:         when :>>
216:           sql << complex_expression_arg_pairs(args){|a, b| "(#{literal(a)} / POWER(2, #{literal(b)}))"}
217:         when 'B~''B~'
218:           literal_append(sql, SQL::Function.new(:BITNOT, *args))
219:         when :extract
220:           sql << args.at(0).to_s
221:           sql << PAREN_OPEN
222:           literal_append(sql, args.at(1))
223:           sql << PAREN_CLOSE
224:         else
225:           super
226:         end
227:       end

DB2 supports GROUP BY CUBE

[Source]

     # File lib/sequel/adapters/shared/db2.rb, line 230
230:       def supports_group_cube?
231:         true
232:       end

DB2 supports GROUP BY ROLLUP

[Source]

     # File lib/sequel/adapters/shared/db2.rb, line 235
235:       def supports_group_rollup?
236:         true
237:       end

DB2 does not support IS TRUE.

[Source]

     # File lib/sequel/adapters/shared/db2.rb, line 240
240:       def supports_is_true?
241:         false
242:       end

DB2 does not support multiple columns in IN.

[Source]

     # File lib/sequel/adapters/shared/db2.rb, line 245
245:       def supports_multiple_column_in?
246:         false
247:       end

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

[Source]

     # File lib/sequel/adapters/shared/db2.rb, line 250
250:       def supports_select_all_and_column?
251:         false
252:       end

DB2 does not support fractional seconds in timestamps.

[Source]

     # File lib/sequel/adapters/shared/db2.rb, line 255
255:       def supports_timestamp_usecs?
256:         false
257:       end

DB2 does not support WHERE 1.

[Source]

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

DB2 supports window functions

[Source]

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

[Validate]