module Sequel::SqlAnywhere::DatasetMethods
Public Instance Methods
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 302 def complex_expression_sql_append(sql, op, args) 303 case op 304 when :'||' 305 super(sql, :+, args) 306 when :<<, :>> 307 complex_expression_emulate_append(sql, op, args) 308 when :LIKE, :"NOT LIKE" 309 sql << '(' 310 literal_append(sql, args[0]) 311 sql << (op == :LIKE ? ' REGEXP ' : ' NOT REGEXP ') 312 pattern = String.new 313 last_c = '' 314 args[1].each_char do |c| 315 if c == '_' and not pattern.end_with?('\\') and last_c != '\\' 316 pattern << '.' 317 elsif c == '%' and not pattern.end_with?('\\') and last_c != '\\' 318 pattern << '.*' 319 elsif c == '[' and not pattern.end_with?('\\') and last_c != '\\' 320 pattern << '\[' 321 elsif c == ']' and not pattern.end_with?('\\') and last_c != '\\' 322 pattern << '\]' 323 elsif c == '*' and not pattern.end_with?('\\') and last_c != '\\' 324 pattern << '\*' 325 elsif c == '?' and not pattern.end_with?('\\') and last_c != '\\' 326 pattern << '\?' 327 else 328 pattern << c 329 end 330 if c == '\\' and last_c == '\\' 331 last_c = '' 332 else 333 last_c = c 334 end 335 end 336 literal_append(sql, pattern) 337 sql << " ESCAPE " 338 literal_append(sql, "\\") 339 sql << ')' 340 when :ILIKE, :"NOT ILIKE" 341 super(sql, (op == :ILIKE ? :LIKE : :"NOT LIKE"), args) 342 when :extract 343 sql << 'datepart(' 344 literal_append(sql, args[0]) 345 sql << ',' 346 literal_append(sql, args[1]) 347 sql << ')' 348 else 349 super 350 end 351 end
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 359 def constant_sql_append(sql, constant) 360 case constant 361 when :CURRENT_DATE 362 sql << 'today()' 363 when :CURRENT_TIMESTAMP, :CURRENT_TIME 364 sql << 'now()' 365 else 366 super 367 end 368 end
Use today() for CURRENT_DATE and now() for CURRENT_TIMESTAMP and CURRENT_TIME
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 250 def convert_smallint_to_bool 251 opts.has_key?(:convert_smallint_to_bool) ? opts[:convert_smallint_to_bool] : db.convert_smallint_to_bool 252 end
Whether to convert smallint to boolean arguments for this dataset. Defaults to the IBMDB
module setting.
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 293 def cross_apply(table) 294 join_table(:cross_apply, table) 295 end
Uses CROSS APPLY to join the given table into the current dataset.
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 354 def escape_like(string) 355 string.gsub(/[\\%_\[]/){|m| "\\#{m}"} 356 end
SqlAnywhere
uses \ to escape metacharacters, but a ‘]’ should not be escaped
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 371 def into(table) 372 clone(:into => table) 373 end
Specify a table for a SELECT … INTO query.
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 298 def recursive_cte_requires_column_aliases? 299 true 300 end
SqlAnywhere
requires recursive CTEs to have column aliases.
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 259 def supports_cte?(type=:select) 260 type == :select 261 end
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 264 def supports_grouping_sets? 265 true 266 end
SQLAnywhere supports GROUPING SETS
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 276 def supports_is_true? 277 false 278 end
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 280 def supports_join_using? 281 false 282 end
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 268 def supports_multiple_column_in? 269 false 270 end
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 272 def supports_where_true? 273 false 274 end
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 284 def supports_window_clause? 285 true 286 end
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 288 def supports_window_functions? 289 true 290 end
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 255 def with_convert_smallint_to_bool(v) 256 clone(:convert_smallint_to_bool=>v) 257 end
Return a cloned dataset with the convert_smallint_to_bool
option set.
Private Instance Methods
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 378 def default_time_format 379 "'%H:%M:%S.%3N'" 380 end
SQLAnywhere only supports 3 digits after the decimal point for times.
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 383 def default_timestamp_format 384 "'%Y-%m-%d %H:%M:%S.%3N'" 385 end
SQLAnywhere only supports 3 digits after the decimal point for timestamps.
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 453 def join_type_sql(join_type) 454 case join_type 455 when :cross_apply 456 'CROSS APPLY' 457 when :outer_apply 458 'OUTER APPLY' 459 else 460 super 461 end 462 end
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 403 def literal_blob_append(sql, v) 404 if v.empty? 405 literal_append(sql, "") 406 else 407 sql << "0x" << v.unpack("H*").first 408 end 409 end
SqlAnywhere
uses a preceding X for hex escaping strings
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 393 def literal_false 394 '0' 395 end
Use 0 for false on Sybase
Source
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 388 def literal_true 389 '1' 390 end
Use 1 for true on Sybase
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 412 def multi_insert_sql_strategy 413 :values 414 end
Sybase supports multiple rows in INSERT.
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 417 def requires_emulating_nulls_first? 418 true 419 end
SQLAnywhere does not natively support NULLS FIRST/LAST.
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 421 def select_into_sql(sql) 422 if i = @opts[:into] 423 sql << " INTO " 424 identifier_append(sql, i) 425 end 426 end
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 429 def select_limit_sql(sql) 430 l = @opts[:limit] 431 o = @opts[:offset] 432 if l || o 433 if l 434 sql << " TOP " 435 literal_append(sql, l) 436 else 437 sql << " TOP 2147483647" 438 end 439 440 if o 441 sql << " START AT (" 442 literal_append(sql, o) 443 sql << " + 1)" 444 end 445 end 446 end
Sybase uses TOP N for limit.
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 449 def select_with_sql_base 450 opts[:with].any?{|w| w[:recursive]} ? "WITH RECURSIVE " : super 451 end
Use WITH RECURSIVE instead of WITH if any of the CTEs is recursive
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 465 def timestamp_precision 466 3 467 end
SQLAnywhere supports millisecond timestamp precision.