Module: Sequel::DB2::DatasetMethods
- Includes:
- EmulateOffsetWithRowNumber
- Included in:
- Dataset, IBMDB::Dataset
- Defined in:
- lib/sequel/adapters/shared/db2.rb
Constant Summary collapse
- 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
Instance Method Summary collapse
-
#cast_sql_append(sql, expr, type) ⇒ Object
DB2 casts strings using RTRIM and CHAR instead of VARCHAR.
-
#complex_expression_sql_append(sql, op, args) ⇒ Object
Handle DB2 specific LIKE and bitwise operator support, and emulate the extract method, which DB2 doesn’t natively support.
-
#supports_group_cube? ⇒ Boolean
DB2 supports GROUP BY CUBE.
-
#supports_group_rollup? ⇒ Boolean
DB2 supports GROUP BY ROLLUP.
-
#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_append(sql, expr, type) ⇒ Object
DB2 casts strings using RTRIM and CHAR instead of VARCHAR.
210 211 212 213 214 215 216 217 218 |
# File 'lib/sequel/adapters/shared/db2.rb', line 210 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) ⇒ Object
Handle DB2 specific LIKE and bitwise operator support, and emulate the extract method, which DB2 doesn’t natively support.
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
# File 'lib/sequel/adapters/shared/db2.rb', line 222 def complex_expression_sql_append(sql, op, args) case op when :ILIKE super(sql, :LIKE, [SQL::Function.new(:upper, args.at(0)), SQL::Function.new(:upper, args.at(1)) ]) when :"NOT ILIKE" super(sql, :"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] 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? ⇒ Boolean
DB2 supports GROUP BY CUBE
251 252 253 |
# File 'lib/sequel/adapters/shared/db2.rb', line 251 def supports_group_cube? true end |
#supports_group_rollup? ⇒ Boolean
DB2 supports GROUP BY ROLLUP
256 257 258 |
# File 'lib/sequel/adapters/shared/db2.rb', line 256 def supports_group_rollup? true end |
#supports_is_true? ⇒ Boolean
DB2 does not support IS TRUE.
261 262 263 |
# File 'lib/sequel/adapters/shared/db2.rb', line 261 def supports_is_true? false end |
#supports_multiple_column_in? ⇒ Boolean
DB2 does not support multiple columns in IN.
266 267 268 |
# File 'lib/sequel/adapters/shared/db2.rb', line 266 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.
271 272 273 |
# File 'lib/sequel/adapters/shared/db2.rb', line 271 def supports_select_all_and_column? false end |
#supports_timestamp_usecs? ⇒ Boolean
DB2 does not support fractional seconds in timestamps.
276 277 278 |
# File 'lib/sequel/adapters/shared/db2.rb', line 276 def false end |
#supports_where_true? ⇒ Boolean
DB2 does not support WHERE 1.
286 287 288 |
# File 'lib/sequel/adapters/shared/db2.rb', line 286 def supports_where_true? false end |
#supports_window_functions? ⇒ Boolean
DB2 supports window functions
281 282 283 |
# File 'lib/sequel/adapters/shared/db2.rb', line 281 def supports_window_functions? true end |