module Sequel::SqlAnywhere::DatasetMethods

Constants

APOS
APOS_RE
BACKSLASH_RE
BLOB_START
BOOL_FALSE
BOOL_TRUE
CROSS_APPLY
DATEPART
DATE_FUNCTION
DOUBLE_APOS
HSTAR
NOT_REGEXP
NOW_FUNCTION
ONLY_OFFSET
OUTER_APPLY
QUAD_BACKSLASH
REGEXP
SQL_WITH_RECURSIVE
START_AT
TOP
WILDCARD

Attributes

convert_smallint_to_bool[W]

Override the default Sequel::SqlAnywhere.convert_smallint_to_bool setting for this dataset.

Public Instance Methods

complex_expression_sql_append(sql, op, args) click to toggle source

SQLAnywhere uses + for string concatenation, and LIKE is case insensitive by default.

# File lib/sequel/adapters/shared/sqlanywhere.rb, line 371
def complex_expression_sql_append(sql, op, args)
  case op
  when :'||'
    super(sql, :+, args)
  when :<<, :>>
    complex_expression_emulate_append(sql, op, args)
  when :LIKE, :"NOT LIKE"
    sql << '('
    literal_append(sql, args[0])
    sql << (op == :LIKE ? ' REGEXP ' : ' NOT REGEXP ')
    pattern = String.new
    last_c = ''
    args[1].each_char do |c|
      if  c == '_' and not pattern.end_with?('\') and last_c != '\'
        pattern << '.'
      elsif c == '%' and not pattern.end_with?('\') and last_c != '\'
        pattern << '.*'
      elsif c == '[' and not pattern.end_with?('\') and last_c != '\'
        pattern << '\['
      elsif c == ']' and not pattern.end_with?('\') and last_c != '\'
        pattern << '\]'
      elsif c == '*' and not pattern.end_with?('\') and last_c != '\'
        pattern << '\*'
      elsif c == '?' and not pattern.end_with?('\') and last_c != '\'
        pattern << '\?'
      else
        pattern << c
      end
      if c == '\' and last_c == '\'
        last_c = ''
      else
        last_c = c
      end
    end
    literal_append(sql, pattern)
    sql << " ESCAPE "
    literal_append(sql, "\\")
    sql << ')'
  when :ILIKE, :"NOT ILIKE"
    super(sql, (op == :ILIKE ? :LIKE : :"NOT LIKE"), args)
  when :extract
    sql << 'datepart('
    literal_append(sql, args[0])
    sql << ','
    literal_append(sql, args[1])
    sql << ')'
  else
    super
  end
end
constant_sql_append(sql, constant) click to toggle source

Use Date() and Now() for CURRENT_DATE and CURRENT_TIMESTAMP

# File lib/sequel/adapters/shared/sqlanywhere.rb, line 428
def constant_sql_append(sql, constant)
  case constant
  when :CURRENT_DATE
    sql << 'today()'
  when :CURRENT_TIMESTAMP, :CURRENT_TIME
    sql << 'now()'
  else
    super
  end
end
convert_smallint_to_bool() click to toggle source

Whether to convert smallint to boolean arguments for this dataset. Defaults to the SqlAnywhere module setting.

# File lib/sequel/adapters/shared/sqlanywhere.rb, line 324
def convert_smallint_to_bool
  defined?(@convert_smallint_to_bool) ? @convert_smallint_to_bool : (@convert_smallint_to_bool = @db.convert_smallint_to_bool)
end
cross_apply(table) click to toggle source

Uses CROSS APPLY to join the given table into the current dataset.

# File lib/sequel/adapters/shared/sqlanywhere.rb, line 361
def cross_apply(table)
  join_table(:cross_apply, table)
end
escape_like(string) click to toggle source

SqlAnywhere uses \ to escape metacharacters, but a ‘]’ should not be escaped

# File lib/sequel/adapters/shared/sqlanywhere.rb, line 423
def escape_like(string)
  string.gsub(/[\%_\[]/){|m| "\\#{m}"}
end
into(table) click to toggle source

Specify a table for a SELECT … INTO query.

# File lib/sequel/adapters/shared/sqlanywhere.rb, line 440
def into(table)
  clone(:into => table)
end
recursive_cte_requires_column_aliases?() click to toggle source

SqlAnywhere requires recursive CTEs to have column aliases.

# File lib/sequel/adapters/shared/sqlanywhere.rb, line 366
def recursive_cte_requires_column_aliases?
  true
end
supports_cte?(type=:select) click to toggle source
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 331
def supports_cte?(type=:select)
  type == :select || type == :insert
end
supports_grouping_sets?() click to toggle source

SQLAnywhere supports GROUPING SETS

# File lib/sequel/adapters/shared/sqlanywhere.rb, line 336
def supports_grouping_sets?
  true
end
supports_is_true?() click to toggle source
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 348
def supports_is_true?
  false
end
supports_join_using?() click to toggle source
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 352
def supports_join_using?
  false
end
supports_multiple_column_in?() click to toggle source
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 340
def supports_multiple_column_in?
  false
end
supports_timestamp_usecs?() click to toggle source
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 356
def supports_timestamp_usecs?
  false
end
supports_where_true?() click to toggle source
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 344
def supports_where_true?
  false
end