Included Modules

Class Index [+]

Quicksearch

Sequel::DB2::DatasetMethods

Constants

PAREN_CLOSE
PAREN_OPEN
BITWISE_METHOD_MAP
BOOL_TRUE
BOOL_FALSE
CAST_STRING_OPEN
CAST_STRING_CLOSE
FETCH_FIRST_ROW_ONLY
FETCH_FIRST
ROWS_ONLY
EMPTY_FROM_TABLE

Public Instance Methods

cast_sql_append(sql, expr, type) click to toggle source

DB2 casts strings using RTRIM and CHAR instead of VARCHAR.

     # 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
complex_expression_sql_append(sql, op, args) click to toggle source

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

     # 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"
227:           super(sql, :"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~'
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
supports_group_cube?() click to toggle source

DB2 supports GROUP BY CUBE

     # File lib/sequel/adapters/shared/db2.rb, line 251
251:       def supports_group_cube?
252:         true
253:       end
supports_group_rollup?() click to toggle source

DB2 supports GROUP BY ROLLUP

     # File lib/sequel/adapters/shared/db2.rb, line 256
256:       def supports_group_rollup?
257:         true
258:       end
supports_is_true?() click to toggle source

DB2 does not support IS TRUE.

     # File lib/sequel/adapters/shared/db2.rb, line 261
261:       def supports_is_true?
262:         false
263:       end
supports_multiple_column_in?() click to toggle source

DB2 does not support multiple columns in IN.

     # File lib/sequel/adapters/shared/db2.rb, line 266
266:       def supports_multiple_column_in?
267:         false
268:       end
supports_select_all_and_column?() click to toggle source

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

     # File lib/sequel/adapters/shared/db2.rb, line 271
271:       def supports_select_all_and_column?
272:         false
273:       end
supports_timestamp_usecs?() click to toggle source

DB2 does not support fractional seconds in timestamps.

     # File lib/sequel/adapters/shared/db2.rb, line 276
276:       def supports_timestamp_usecs?
277:         false
278:       end
supports_where_true?() click to toggle source

DB2 does not support WHERE 1.

     # File lib/sequel/adapters/shared/db2.rb, line 286
286:       def supports_where_true?
287:         false
288:       end
supports_window_functions?() click to toggle source

DB2 supports window functions

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

Private Instance Methods

_truncate_sql(table) click to toggle source
     # File lib/sequel/adapters/shared/db2.rb, line 335
335:       def _truncate_sql(table)
336:         # "TRUNCATE #{table} IMMEDIATE" is only for newer version of db2, so we
337:         # use the following one
338:         "ALTER TABLE #{quote_schema_table(table)} ACTIVATE NOT LOGGED INITIALLY WITH EMPTY TABLE"
339:       end
insert_supports_empty_values?() click to toggle source

DB2 needs the standard workaround to insert all default values into a table with more than one column.

     # File lib/sequel/adapters/shared/db2.rb, line 294
294:       def insert_supports_empty_values?
295:         false
296:       end
literal_false() click to toggle source

Use 0 for false on DB2

     # File lib/sequel/adapters/shared/db2.rb, line 299
299:       def literal_false
300:         BOOL_FALSE
301:       end
literal_true() click to toggle source

Use 1 for true on DB2

     # File lib/sequel/adapters/shared/db2.rb, line 304
304:       def literal_true
305:         BOOL_TRUE
306:       end
select_from_sql(sql) click to toggle source

Add a fallback table for empty from situation

     # File lib/sequel/adapters/shared/db2.rb, line 309
309:       def select_from_sql(sql)
310:         @opts[:from] ? super : (sql << EMPTY_FROM_TABLE)
311:       end
select_limit_sql(sql) click to toggle source

Modify the sql to limit the number of rows returned Note:

    After db2 v9.7, MySQL flavored "LIMIT X OFFSET Y" can be enabled using

    db2set DB2_COMPATIBILITY_VECTOR=MYSQL
    db2stop
    db2start

    Support for this feature is not used in this adapter however.
     # File lib/sequel/adapters/shared/db2.rb, line 323
323:       def select_limit_sql(sql)
324:         if l = @opts[:limit]
325:           if l == 1
326:             sql << FETCH_FIRST_ROW_ONLY
327:           else
328:             sql << FETCH_FIRST
329:             literal_append(sql, l)
330:             sql << ROWS_ONLY
331:           end
332:         end
333:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.