Module: Sequel::DB2::DatasetMethods
- Includes:
- EmulateOffsetWithRowNumber
- Included in:
- Dataset, IBMDB::Dataset, JDBC::DB2::Dataset, ODBC::DB2::Dataset
- Defined in:
- lib/sequel/adapters/shared/db2.rb
Constant Summary collapse
- BITWISE_METHOD_MAP =
{:& =>:BITAND, :| => :BITOR, :^ => :BITXOR, :'B~'=>:BITNOT}
- BOOL_TRUE =
'1'.freeze
- BOOL_FALSE =
'0'.freeze
Instance Method Summary collapse
-
#cast_sql(expr, type) ⇒ Object
DB2 casts strings using RTRIM and CHAR instead of VARCHAR.
-
#complex_expression_sql(op, args) ⇒ Object
Handle DB2 specific LIKE and bitwise operator support, and emulate the extract method, which DB2 doesn’t natively support.
-
#supports_is_true? ⇒ Boolean
DB2 does not support IS TRUE.
-
#supports_multiple_column_in? ⇒ Boolean
DB2 does not support multiple columns in IN.
-
#supports_select_all_and_column? ⇒ Boolean
DB2 only allows * in SELECT if it is the only thing being selected.
-
#supports_timestamp_usecs? ⇒ Boolean
DB2 does not support fractional seconds in timestamps.
-
#supports_where_true? ⇒ Boolean
DB2 does not support WHERE 1.
-
#supports_window_functions? ⇒ Boolean
DB2 supports window functions.
Methods included from EmulateOffsetWithRowNumber
Instance Method Details
#cast_sql(expr, type) ⇒ Object
DB2 casts strings using RTRIM and CHAR instead of VARCHAR.
183 184 185 |
# File 'lib/sequel/adapters/shared/db2.rb', line 183 def cast_sql(expr, type) type == String ? "RTRIM(CHAR(#{literal(expr)}))" : super end |
#complex_expression_sql(op, args) ⇒ Object
Handle DB2 specific LIKE and bitwise operator support, and emulate the extract method, which DB2 doesn’t natively support.
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/sequel/adapters/shared/db2.rb', line 189 def complex_expression_sql(op, args) case op when :ILIKE super(:LIKE, [SQL::Function.new(:upper, args.at(0)), SQL::Function.new(:upper, args.at(1)) ]) when :"NOT ILIKE" super(:"NOT LIKE", [SQL::Function.new(:upper, args.at(0)), SQL::Function.new(:upper, args.at(1)) ]) when :&, :|, :^ # works with db2 v9.5 and after op = BITWISE_METHOD_MAP[op] complex_expression_arg_pairs(args){|a, b| literal(SQL::Function.new(op, a, b))} when :<< complex_expression_arg_pairs(args){|a, b| "(#{literal(a)} * POWER(2, #{literal(b)}))"} when :>> complex_expression_arg_pairs(args){|a, b| "(#{literal(a)} / POWER(2, #{literal(b)}))"} when :'B~' literal(SQL::Function.new(:BITNOT, *args)) when :extract "#{args.at(0)}(#{literal(args.at(1))})" else super end end |
#supports_is_true? ⇒ Boolean
DB2 does not support IS TRUE.
213 214 215 |
# File 'lib/sequel/adapters/shared/db2.rb', line 213 def supports_is_true? false end |
#supports_multiple_column_in? ⇒ Boolean
DB2 does not support multiple columns in IN.
218 219 220 |
# File 'lib/sequel/adapters/shared/db2.rb', line 218 def supports_multiple_column_in? false end |
#supports_select_all_and_column? ⇒ Boolean
DB2 only allows * in SELECT if it is the only thing being selected.
223 224 225 |
# File 'lib/sequel/adapters/shared/db2.rb', line 223 def supports_select_all_and_column? false end |
#supports_timestamp_usecs? ⇒ Boolean
DB2 does not support fractional seconds in timestamps.
228 229 230 |
# File 'lib/sequel/adapters/shared/db2.rb', line 228 def false end |
#supports_where_true? ⇒ Boolean
DB2 does not support WHERE 1.
238 239 240 |
# File 'lib/sequel/adapters/shared/db2.rb', line 238 def supports_where_true? false end |
#supports_window_functions? ⇒ Boolean
DB2 supports window functions
233 234 235 |
# File 'lib/sequel/adapters/shared/db2.rb', line 233 def supports_window_functions? true end |