Module: Sequel::DB2::DatasetMethods

Includes:
EmulateOffsetWithRowNumber
Included in:
Dataset, IBMDB::Dataset, JDBC::DB2::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}
EMULATED_FUNCTION_MAP =
{:char_length=>'length'.freeze}
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
HSTAR =
"H*".freeze
BLOB_OPEN =
"BLOB(X'".freeze
BLOB_CLOSE =
"')".freeze

Instance Method Summary collapse

Methods included from EmulateOffsetWithRowNumber

#select_sql, #supports_offsets_in_correlated_subqueries?

Instance Method Details

#cast_sql_append(sql, expr, type) ⇒ Object

DB2 casts strings using RTRIM and CHAR instead of VARCHAR.



253
254
255
256
257
258
259
260
261
# File 'lib/sequel/adapters/shared/db2.rb', line 253

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



263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
# File 'lib/sequel/adapters/shared/db2.rb', line 263

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

#supports_cte?(type = :select) ⇒ Boolean

Returns:

  • (Boolean)


279
280
281
# File 'lib/sequel/adapters/shared/db2.rb', line 279

def supports_cte?(type=:select)
  type == :select
end

#supports_group_cube?Boolean

DB2 supports GROUP BY CUBE

Returns:

  • (Boolean)


284
285
286
# File 'lib/sequel/adapters/shared/db2.rb', line 284

def supports_group_cube?
  true
end

#supports_group_rollup?Boolean

DB2 supports GROUP BY ROLLUP

Returns:

  • (Boolean)


289
290
291
# File 'lib/sequel/adapters/shared/db2.rb', line 289

def supports_group_rollup?
  true
end

#supports_is_true?Boolean

DB2 does not support IS TRUE.

Returns:

  • (Boolean)


294
295
296
# File 'lib/sequel/adapters/shared/db2.rb', line 294

def supports_is_true?
  false
end

#supports_lateral_subqueries?Boolean

DB2 supports lateral subqueries

Returns:

  • (Boolean)


299
300
301
# File 'lib/sequel/adapters/shared/db2.rb', line 299

def supports_lateral_subqueries?
  true
end

#supports_multiple_column_in?Boolean

DB2 does not support multiple columns in IN.

Returns:

  • (Boolean)


304
305
306
# File 'lib/sequel/adapters/shared/db2.rb', line 304

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.

Returns:

  • (Boolean)


309
310
311
# File 'lib/sequel/adapters/shared/db2.rb', line 309

def supports_select_all_and_column?
  false
end

#supports_timestamp_usecs?Boolean

DB2 does not support fractional seconds in timestamps.

Returns:

  • (Boolean)


314
315
316
# File 'lib/sequel/adapters/shared/db2.rb', line 314

def supports_timestamp_usecs?
  false
end

#supports_where_true?Boolean

DB2 does not support WHERE 1.

Returns:

  • (Boolean)


324
325
326
# File 'lib/sequel/adapters/shared/db2.rb', line 324

def supports_where_true?
  false
end

#supports_window_functions?Boolean

DB2 supports window functions

Returns:

  • (Boolean)


319
320
321
# File 'lib/sequel/adapters/shared/db2.rb', line 319

def supports_window_functions?
  true
end