Module | Sequel::SqlAnywhere::DatasetMethods |
In: |
lib/sequel/adapters/shared/sqlanywhere.rb
|
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 293 293: def complex_expression_sql_append(sql, op, args) 294: case op 295: when '||''||' 296: super(sql, :+, args) 297: when :<<, :>> 298: complex_expression_emulate_append(sql, op, args) 299: when :LIKE, "NOT LIKE""NOT LIKE" 300: sql << '(' 301: literal_append(sql, args[0]) 302: sql << (op == :LIKE ? ' REGEXP ' : ' NOT REGEXP ') 303: pattern = String.new 304: last_c = '' 305: args[1].each_char do |c| 306: if c == '_' and not pattern.end_with?('\\') and last_c != '\\' 307: pattern << '.' 308: elsif c == '%' and not pattern.end_with?('\\') and last_c != '\\' 309: pattern << '.*' 310: elsif c == '[' and not pattern.end_with?('\\') and last_c != '\\' 311: pattern << '\[' 312: elsif c == ']' and not pattern.end_with?('\\') and last_c != '\\' 313: pattern << '\]' 314: elsif c == '*' and not pattern.end_with?('\\') and last_c != '\\' 315: pattern << '\*' 316: elsif c == '?' and not pattern.end_with?('\\') and last_c != '\\' 317: pattern << '\?' 318: else 319: pattern << c 320: end 321: if c == '\\' and last_c == '\\' 322: last_c = '' 323: else 324: last_c = c 325: end 326: end 327: literal_append(sql, pattern) 328: sql << " ESCAPE " 329: literal_append(sql, "\\") 330: sql << ')' 331: when :ILIKE, "NOT ILIKE""NOT ILIKE" 332: super(sql, (op == :ILIKE ? :LIKE : "NOT LIKE""NOT LIKE"), args) 333: when :extract 334: sql << 'datepart(' 335: literal_append(sql, args[0]) 336: sql << ',' 337: literal_append(sql, args[1]) 338: sql << ')' 339: else 340: super 341: end 342: end
Use today() for CURRENT_DATE and now() for CURRENT_TIMESTAMP and CURRENT_TIME
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 350 350: def constant_sql_append(sql, constant) 351: case constant 352: when :CURRENT_DATE 353: sql << 'today()' 354: when :CURRENT_TIMESTAMP, :CURRENT_TIME 355: sql << 'now()' 356: else 357: super 358: end 359: end
Whether to convert smallint to boolean arguments for this dataset. Defaults to the IBMDB module setting.
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 245 245: def convert_smallint_to_bool 246: opts.has_key?(:convert_smallint_to_bool) ? opts[:convert_smallint_to_bool] : db.convert_smallint_to_bool 247: end
SqlAnywhere uses \ to escape metacharacters, but a ’]’ should not be escaped
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 345 345: def escape_like(string) 346: string.gsub(/[\\%_\[]/){|m| "\\#{m}"} 347: end
Specify a table for a SELECT … INTO query.
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 362 362: def into(table) 363: clone(:into => table) 364: end
SqlAnywhere requires recursive CTEs to have column aliases.
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 289 289: def recursive_cte_requires_column_aliases? 290: true 291: end
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 254 254: def supports_cte?(type=:select) 255: type == :select || type == :insert 256: end
SQLAnywhere supports GROUPING SETS
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 259 259: def supports_grouping_sets? 260: true 261: end
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 271 271: def supports_is_true? 272: false 273: end
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 275 275: def supports_join_using? 276: false 277: end
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 263 263: def supports_multiple_column_in? 264: false 265: end
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 279 279: def supports_timestamp_usecs? 280: false 281: end
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 267 267: def supports_where_true? 268: false 269: end
Return a cloned dataset with the convert_smallint_to_bool option set.
# File lib/sequel/adapters/shared/sqlanywhere.rb, line 250 250: def with_convert_smallint_to_bool(v) 251: clone(:convert_smallint_to_bool=>v) 252: end