module Sequel::SqlAnywhere::DatasetMethods

  1. lib/sequel/adapters/shared/sqlanywhere.rb
Parent: SqlAnywhere

Constants

APOS = Dataset::APOS  
APOS_RE = Dataset::APOS_RE  
BACKSLASH_RE = /\\/.freeze  
BLOB_START = "0x".freeze  
BOOL_FALSE = '0'.freeze  
BOOL_TRUE = '1'.freeze  
CROSS_APPLY = 'CROSS APPLY'.freeze  
DATEPART = 'datepart'.freeze  
DATE_FUNCTION = 'today()'.freeze  
DOUBLE_APOS = Dataset::DOUBLE_APOS  
HSTAR = "H*".freeze  
INSERT_CLAUSE_METHODS = Dataset.clause_methods(:insert, %w'with insert into columns values')  
NOT_REGEXP = 'NOT REGEXP'.freeze  
NOW_FUNCTION = 'now()'.freeze  
OUTER_APPLY = 'OUTER APPLY'.freeze  
QUAD_BACKSLASH = "\\\\\\\\".freeze  
REGEXP = 'REGEXP'.freeze  
SELECT_CLAUSE_METHODS = Dataset.clause_methods(:select, %w'with select distinct limit columns into from join where group having order compounds lock')  
SQL_WITH_RECURSIVE = "WITH RECURSIVE ".freeze  
START_AT = " START AT ".freeze  
TIMESTAMP_USEC_FORMAT = ".%03d".freeze  
TOP = " TOP ".freeze  
WILDCARD = LiteralString.new('%').freeze  

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)

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

[show source]
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 305
def complex_expression_sql_append(sql, op, args)
  case op
  when :'||'
    super(sql, :+, args)
  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 :LIKE, :"NOT LIKE"
    sql << Sequel::Dataset::PAREN_OPEN
    literal_append(sql, args.at(0))
    sql << Sequel::Dataset::SPACE << (op == :LIKE ? REGEXP : NOT_REGEXP) << Sequel::Dataset::SPACE
    pattern = ''
    last_c = ''
    args.at(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 << Sequel::Dataset::ESCAPE
    literal_append(sql, Sequel::Dataset::BACKSLASH)
    sql << Sequel::Dataset::PAREN_CLOSE
  when :ILIKE, :"NOT ILIKE"
    super(sql, (op == :ILIKE ? :LIKE : :"NOT LIKE"), args)
  when :extract
    sql << DATEPART + Sequel::Dataset::PAREN_OPEN
    literal_append(sql, args.at(0))
    sql << ','
    literal_append(sql, args.at(1))
    sql << Sequel::Dataset::PAREN_CLOSE
  else
    super
  end
end
constant_sql_append (sql, constant)

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

[show source]
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 364
def constant_sql_append(sql, constant)
  case constant
  when :CURRENT_DATE
    sql << DATE_FUNCTION
  when :CURRENT_TIMESTAMP, :CURRENT_TIME
    sql << NOW_FUNCTION
  else
    super
  end
end
convert_smallint_to_bool ()

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

[show source]
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 267
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)

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

[show source]
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 295
def cross_apply(table)
  join_table(:cross_apply, table)
end
escape_like (string)

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

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

Specify a table for a SELECT … INTO query.

[show source]
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 376
def into(table)
  clone(:into => table)
end
recursive_cte_requires_column_aliases? ()

SqlAnywhere requires recursive CTEs to have column aliases.

[show source]
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 300
def recursive_cte_requires_column_aliases?
  true
end
supports_is_true? ()
[show source]
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 282
def supports_is_true?
  false
end
supports_join_using? ()
[show source]
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 286
def supports_join_using?
  false
end
supports_multiple_column_in? ()
[show source]
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 274
def supports_multiple_column_in?
  false
end
supports_timestamp_usecs? ()
[show source]
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 290
def supports_timestamp_usecs?
  false
end
supports_where_true? ()
[show source]
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 278
def supports_where_true?
  false
end