module Sequel::DB2::DatasetMethods
Constants
- BITWISE_METHOD_MAP
- BLOB_CLOSE
- BLOB_OPEN
- BOOL_FALSE
- BOOL_TRUE
- CAST_STRING_CLOSE
- CAST_STRING_OPEN
- EMPTY_FROM_TABLE
- EMULATED_FUNCTION_MAP
- FETCH_FIRST
- FETCH_FIRST_ROW_ONLY
- HSTAR
- PAREN_CLOSE
- PAREN_OPEN
- ROWS_ONLY
Public Instance Methods
DB2 casts strings using RTRIM and CHAR instead of VARCHAR.
# File lib/sequel/adapters/shared/db2.rb, line 303 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
# File lib/sequel/adapters/shared/db2.rb, line 313 def complex_expression_sql_append(sql, op, args) case op when :&, :|, :^, :%, :<<, :>> complex_expression_emulate_append(sql, op, args) 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
# File lib/sequel/adapters/shared/db2.rb, line 329 def quote_identifiers? @opts.fetch(:quote_identifiers, false) end
# File lib/sequel/adapters/shared/db2.rb, line 333 def supports_cte?(type=:select) type == :select end
DB2 supports GROUP BY CUBE
# File lib/sequel/adapters/shared/db2.rb, line 338 def supports_group_cube? true end
DB2 supports GROUP BY ROLLUP
# File lib/sequel/adapters/shared/db2.rb, line 343 def supports_group_rollup? true end
DB2 supports GROUPING SETS
# File lib/sequel/adapters/shared/db2.rb, line 348 def supports_grouping_sets? true end
DB2 does not support IS TRUE.
# File lib/sequel/adapters/shared/db2.rb, line 353 def supports_is_true? false end
DB2 supports lateral subqueries
# File lib/sequel/adapters/shared/db2.rb, line 358 def supports_lateral_subqueries? true end
DB2 does not support multiple columns in IN.
# File lib/sequel/adapters/shared/db2.rb, line 363 def supports_multiple_column_in? false end
DB2 only allows * in SELECT if it is the only thing being selected.
# File lib/sequel/adapters/shared/db2.rb, line 368 def supports_select_all_and_column? false end
DB2 does not support fractional seconds in timestamps.
# File lib/sequel/adapters/shared/db2.rb, line 373 def supports_timestamp_usecs? false end
DB2 does not support WHERE 1.
# File lib/sequel/adapters/shared/db2.rb, line 383 def supports_where_true? false end
DB2 supports window functions
# File lib/sequel/adapters/shared/db2.rb, line 378 def supports_window_functions? true end
Private Instance Methods
# File lib/sequel/adapters/shared/db2.rb, line 464 def _truncate_sql(table) # "TRUNCATE #{table} IMMEDIATE" is only for newer version of db2, so we # use the following one "ALTER TABLE #{quote_schema_table(table)} ACTIVATE NOT LOGGED INITIALLY WITH EMPTY TABLE" end
# File lib/sequel/adapters/shared/db2.rb, line 389 def empty_from_sql EMPTY_FROM_TABLE end
Emulate offset with row number by default, and also when the limit_offset strategy is used without a limit, as DB2 doesn't support that syntax with no limit.
# File lib/sequel/adapters/shared/db2.rb, line 396 def emulate_offset_with_row_number? super && (db.offset_strategy == :emulate || (db.offset_strategy == :limit_offset && !@opts[:limit])) end
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 402 def insert_supports_empty_values? false end
DB2 uses a literal hexidecimal number for blob strings
# File lib/sequel/adapters/shared/db2.rb, line 417 def literal_blob_append(sql, v) if ::Sequel::DB2.use_clob_as_blob super else sql << BLOB_OPEN << v.unpack(HSTAR).first << BLOB_CLOSE end end
Use 0 for false on DB2
# File lib/sequel/adapters/shared/db2.rb, line 407 def literal_false BOOL_FALSE end
Use 1 for true on DB2
# File lib/sequel/adapters/shared/db2.rb, line 412 def literal_true BOOL_TRUE end
DB2 can insert multiple rows using a UNION
# File lib/sequel/adapters/shared/db2.rb, line 426 def multi_insert_sql_strategy :union end
DB2 does not require that ROW_NUMBER be ordered.
# File lib/sequel/adapters/shared/db2.rb, line 431 def require_offset_order? false end
Modify the sql to limit the number of rows returned. Uses :offset_strategy Database option to determine how to format the limit and offset.
# File lib/sequel/adapters/shared/db2.rb, line 438 def select_limit_sql(sql) strategy = db.offset_strategy return super if strategy == :limit_offset if strategy == :offset_fetch && (o = @opts[:offset]) sql << " OFFSET " literal_append(sql, o) sql << " ROWS" end if l = @opts[:limit] if l == 1 sql << FETCH_FIRST_ROW_ONLY else sql << FETCH_FIRST literal_append(sql, l) sql << ROWS_ONLY end end end
DB2 supports quoted function names.
# File lib/sequel/adapters/shared/db2.rb, line 460 def supports_quoted_function_names? true end