module Sequel::DB2::DatasetMethods

  1. lib/sequel/adapters/shared/db2.rb
Parent: DB2

Included modules

  1. EmulateOffsetWithRowNumber

Constants

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

Public Instance methods

cast_sql_append (sql, expr, type)

DB2 casts strings using RTRIM and CHAR instead of VARCHAR.

[show source]
# File lib/sequel/adapters/shared/db2.rb, line 247
def cast_sql_append(sql, expr, type)
  if(type == String)
    sql << CAST_STRING_OPEN
    literal_append(sql, expr)
    sql << CAST_STRING_CLOSE
  else
    super
  end
end
complex_expression_sql_append (sql, op, args)
[show source]
# File lib/sequel/adapters/shared/db2.rb, line 257
def complex_expression_sql_append(sql, op, args)
  case op
  when :&, :|, :^
    # works with db2 v9.5 and after
    op = BITWISE_METHOD_MAP[op]
    sql << complex_expression_arg_pairs(args){|a, b| literal(SQL::Function.new(op, a, b))}
  when :<<
    sql << complex_expression_arg_pairs(args){|a, b| "(#{literal(a)} * POWER(2, #{literal(b)}))"}
  when :>>
    sql << complex_expression_arg_pairs(args){|a, b| "(#{literal(a)} / POWER(2, #{literal(b)}))"}
  when :%
    sql << complex_expression_arg_pairs(args){|a, b| "MOD(#{literal(a)}, #{literal(b)})"}
  when :'B~'
    literal_append(sql, SQL::Function.new(:BITNOT, *args))
  when :extract
    sql << args.at(0).to_s
    sql << PAREN_OPEN
    literal_append(sql, args.at(1))
    sql << PAREN_CLOSE
  else
    super
  end
end
supports_group_cube? ()

DB2 supports GROUP BY CUBE

[show source]
# File lib/sequel/adapters/shared/db2.rb, line 282
def supports_group_cube?
  true
end
supports_group_rollup? ()

DB2 supports GROUP BY ROLLUP

[show source]
# File lib/sequel/adapters/shared/db2.rb, line 287
def supports_group_rollup?
  true
end
supports_is_true? ()

DB2 does not support IS TRUE.

[show source]
# File lib/sequel/adapters/shared/db2.rb, line 292
def supports_is_true?
  false
end
supports_lateral_subqueries? ()

DB2 supports lateral subqueries

[show source]
# File lib/sequel/adapters/shared/db2.rb, line 297
def supports_lateral_subqueries?
  true
end
supports_multiple_column_in? ()

DB2 does not support multiple columns in IN.

[show source]
# File lib/sequel/adapters/shared/db2.rb, line 302
def supports_multiple_column_in?
  false
end
supports_select_all_and_column? ()

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

[show source]
# File lib/sequel/adapters/shared/db2.rb, line 307
def supports_select_all_and_column?
  false
end
supports_timestamp_usecs? ()

DB2 does not support fractional seconds in timestamps.

[show source]
# File lib/sequel/adapters/shared/db2.rb, line 312
def supports_timestamp_usecs?
  false
end
supports_where_true? ()

DB2 does not support WHERE 1.

[show source]
# File lib/sequel/adapters/shared/db2.rb, line 322
def supports_where_true?
  false
end
supports_window_functions? ()

DB2 supports window functions

[show source]
# File lib/sequel/adapters/shared/db2.rb, line 317
def supports_window_functions?
  true
end