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 325
325:       def complex_expression_sql_append(sql, op, args)
326:         case op
327:         when '||''||'
328:           super(sql, :+, args)
329:         when :<<, :>>
330:           complex_expression_emulate_append(sql, op, args)
331:         when :LIKE, "NOT LIKE""NOT LIKE"
332:           sql << Sequel::Dataset::PAREN_OPEN
333:           literal_append(sql, args.at(0))
334:           sql << Sequel::Dataset::SPACE << (op == :LIKE ? REGEXP : NOT_REGEXP) << Sequel::Dataset::SPACE
335:           pattern = String.new
336:           last_c = ''
337:           args.at(1).each_char do |c|
338:             if  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:             elsif c == '[' and not pattern.end_with?('\\') and last_c != '\\'
343:               pattern << '\['
344:             elsif c == ']' and not pattern.end_with?('\\') and last_c != '\\'
345:               pattern << '\]'
346:             elsif c == '*' and not pattern.end_with?('\\') and last_c != '\\'
347:               pattern << '\*'
348:             elsif c == '?' and not pattern.end_with?('\\') and last_c != '\\'
349:               pattern << '\?'
350:             else
351:               pattern << c
352:             end
353:             if c == '\\' and last_c == '\\'
354:               last_c = ''
355:             else
356:               last_c = c
357:             end
358:           end
359:           literal_append(sql, pattern)
360:           sql << Sequel::Dataset::ESCAPE
361:           literal_append(sql, Sequel::Dataset::BACKSLASH)
362:           sql << Sequel::Dataset::PAREN_CLOSE
363:         when :ILIKE, "NOT ILIKE""NOT ILIKE"
364:           super(sql, (op == :ILIKE ? :LIKE : "NOT LIKE""NOT LIKE"), args)
365:         when :extract
366:           sql << DATEPART + Sequel::Dataset::PAREN_OPEN
367:           literal_append(sql, args.at(0))
368:           sql << ','
369:           literal_append(sql, args.at(1))
370:           sql << Sequel::Dataset::PAREN_CLOSE
371:         else
372:           super
373:         end
374:       end

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

[Source]

     # File lib/sequel/adapters/shared/sqlanywhere.rb, line 382
382:       def constant_sql_append(sql, constant)
383:         case constant
384:         when :CURRENT_DATE
385:           sql << DATE_FUNCTION
386:         when :CURRENT_TIMESTAMP, :CURRENT_TIME
387:           sql << NOW_FUNCTION
388:         else
389:           super
390:         end
391:       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 278
278:       def convert_smallint_to_bool
279:         defined?(@convert_smallint_to_bool) ? @convert_smallint_to_bool : (@convert_smallint_to_bool = @db.convert_smallint_to_bool)
280:       end

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

[Source]

     # File lib/sequel/adapters/shared/sqlanywhere.rb, line 315
315:       def cross_apply(table)
316:         join_table(:cross_apply, table)
317:       end

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

[Source]

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

Specify a table for a SELECT … INTO query.

[Source]

     # File lib/sequel/adapters/shared/sqlanywhere.rb, line 394
394:       def into(table)
395:         clone(:into => table)
396:       end

SqlAnywhere requires recursive CTEs to have column aliases.

[Source]

     # File lib/sequel/adapters/shared/sqlanywhere.rb, line 320
320:       def recursive_cte_requires_column_aliases?
321:         true
322:       end

[Source]

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

SQLAnywhere supports GROUPING SETS

[Source]

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

[Source]

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

[Source]

     # File lib/sequel/adapters/shared/sqlanywhere.rb, line 306
306:       def supports_join_using?
307:         false
308:       end

[Source]

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

[Source]

     # File lib/sequel/adapters/shared/sqlanywhere.rb, line 310
310:       def supports_timestamp_usecs?
311:         false
312:       end

[Source]

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

[Validate]