Module Sequel::SqlAnywhere::DatasetMethods
In: lib/sequel/adapters/shared/sqlanywhere.rb

Methods

Constants

BOOL_TRUE = '1'.freeze
BOOL_FALSE = '0'.freeze
WILDCARD = LiteralString.new('%').freeze
TOP = " TOP ".freeze
START_AT = " START AT ".freeze
SQL_WITH_RECURSIVE = "WITH RECURSIVE ".freeze
DATE_FUNCTION = 'today()'.freeze
NOW_FUNCTION = 'now()'.freeze
DATEPART = 'datepart'.freeze
REGEXP = 'REGEXP'.freeze
NOT_REGEXP = 'NOT REGEXP'.freeze
APOS = Dataset::APOS
APOS_RE = Dataset::APOS_RE
DOUBLE_APOS = Dataset::DOUBLE_APOS
BACKSLASH_RE = /\\/.freeze
QUAD_BACKSLASH = "\\\\\\\\".freeze
BLOB_START = "0x".freeze
HSTAR = "H*".freeze
CROSS_APPLY = 'CROSS APPLY'.freeze
OUTER_APPLY = 'OUTER APPLY'.freeze
ONLY_OFFSET = " TOP 2147483647".freeze

Attributes

convert_smallint_to_bool  [W]  Override the default SqlAnywhere.convert_smallint_to_bool setting for this dataset.

Public Instance methods

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

[Source]

     # File lib/sequel/adapters/shared/sqlanywhere.rb, line 317
317:       def complex_expression_sql_append(sql, op, args)
318:         case op
319:         when '||''||'
320:           super(sql, :+, args)
321:         when :<<, :>>
322:           complex_expression_emulate_append(sql, op, args)
323:         when :LIKE, "NOT LIKE""NOT LIKE"
324:           sql << Sequel::Dataset::PAREN_OPEN
325:           literal_append(sql, args.at(0))
326:           sql << Sequel::Dataset::SPACE << (op == :LIKE ? REGEXP : NOT_REGEXP) << Sequel::Dataset::SPACE
327:           pattern = ''
328:           last_c = ''
329:           args.at(1).each_char do |c|
330:             if  c == '_' and not pattern.end_with?('\\') and last_c != '\\'
331:               pattern << '.'
332:             elsif c == '%' and not pattern.end_with?('\\') and last_c != '\\'
333:               pattern << '.*'
334:             elsif c == '[' and not pattern.end_with?('\\') and last_c != '\\'
335:               pattern << '\['
336:             elsif c == ']' and not pattern.end_with?('\\') and last_c != '\\'
337:               pattern << '\]'
338:             elsif c == '*' and not pattern.end_with?('\\') and last_c != '\\'
339:               pattern << '\*'
340:             elsif c == '?' and not pattern.end_with?('\\') and last_c != '\\'
341:               pattern << '\?'
342:             else
343:               pattern << c
344:             end
345:             if c == '\\' and last_c == '\\'
346:               last_c = ''
347:             else
348:               last_c = c
349:             end
350:           end
351:           literal_append(sql, pattern)
352:           sql << Sequel::Dataset::ESCAPE
353:           literal_append(sql, Sequel::Dataset::BACKSLASH)
354:           sql << Sequel::Dataset::PAREN_CLOSE
355:         when :ILIKE, "NOT ILIKE""NOT ILIKE"
356:           super(sql, (op == :ILIKE ? :LIKE : "NOT LIKE""NOT LIKE"), args)
357:         when :extract
358:           sql << DATEPART + Sequel::Dataset::PAREN_OPEN
359:           literal_append(sql, args.at(0))
360:           sql << ','
361:           literal_append(sql, args.at(1))
362:           sql << Sequel::Dataset::PAREN_CLOSE
363:         else
364:           super
365:         end
366:       end

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

[Source]

     # File lib/sequel/adapters/shared/sqlanywhere.rb, line 374
374:       def constant_sql_append(sql, constant)
375:         case constant
376:         when :CURRENT_DATE
377:           sql << DATE_FUNCTION
378:         when :CURRENT_TIMESTAMP, :CURRENT_TIME
379:           sql << NOW_FUNCTION
380:         else
381:           super
382:         end
383:       end

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

[Source]

     # File lib/sequel/adapters/shared/sqlanywhere.rb, line 275
275:       def convert_smallint_to_bool
276:         defined?(@convert_smallint_to_bool) ? @convert_smallint_to_bool : (@convert_smallint_to_bool = @db.convert_smallint_to_bool)
277:       end

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

[Source]

     # File lib/sequel/adapters/shared/sqlanywhere.rb, line 307
307:       def cross_apply(table)
308:         join_table(:cross_apply, table)
309:       end

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

[Source]

     # File lib/sequel/adapters/shared/sqlanywhere.rb, line 369
369:       def escape_like(string)
370:         string.gsub(/[\\%_\[]/){|m| "\\#{m}"}
371:       end

Specify a table for a SELECT … INTO query.

[Source]

     # File lib/sequel/adapters/shared/sqlanywhere.rb, line 386
386:       def into(table)
387:         clone(:into => table)
388:       end

SqlAnywhere requires recursive CTEs to have column aliases.

[Source]

     # File lib/sequel/adapters/shared/sqlanywhere.rb, line 312
312:       def recursive_cte_requires_column_aliases?
313:         true
314:       end

[Source]

     # File lib/sequel/adapters/shared/sqlanywhere.rb, line 282
282:       def supports_cte?(type=:select)
283:         type == :select || type == :insert
284:       end

[Source]

     # File lib/sequel/adapters/shared/sqlanywhere.rb, line 294
294:       def supports_is_true?
295:         false
296:       end

[Source]

     # File lib/sequel/adapters/shared/sqlanywhere.rb, line 298
298:       def supports_join_using?
299:         false
300:       end

[Source]

     # File lib/sequel/adapters/shared/sqlanywhere.rb, line 286
286:       def supports_multiple_column_in?
287:         false
288:       end

[Source]

     # File lib/sequel/adapters/shared/sqlanywhere.rb, line 302
302:       def supports_timestamp_usecs?
303:         false
304:       end

[Source]

     # File lib/sequel/adapters/shared/sqlanywhere.rb, line 290
290:       def supports_where_true?
291:         false
292:       end

[Validate]