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 :ILIKE, :"NOT ILIKE" 309 super(sql, (op == :ILIKE ? :LIKE : :"NOT LIKE"), args) 310 when :extract 311 sql << 'datepart(' 312 literal_append(sql, args[0]) 313 sql << ',' 314 literal_append(sql, args[1]) 315 sql << ')' 316 else 317 super 318 end 319 end
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 327 def constant_sql_append(sql, constant) 328 case constant 329 when :CURRENT_DATE 330 sql << 'today()' 331 when :CURRENT_TIMESTAMP, :CURRENT_TIME 332 sql << 'now()' 333 else 334 super 335 end 336 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 322 def escape_like(string) 323 string.gsub(/[\\%_\[]/){|m| "\\#{m}"} 324 end
SqlAnywhere uses \ to escape metacharacters, but a ‘]’ should not be escaped
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 339 def into(table) 340 clone(:into => table) 341 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 346 def default_time_format 347 "'%H:%M:%S.%3N'" 348 end
SQLAnywhere only supports 3 digits after the decimal point for times.
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 351 def default_timestamp_format 352 "'%Y-%m-%d %H:%M:%S.%3N'" 353 end
SQLAnywhere only supports 3 digits after the decimal point for timestamps.
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 421 def join_type_sql(join_type) 422 case join_type 423 when :cross_apply 424 'CROSS APPLY' 425 when :outer_apply 426 'OUTER APPLY' 427 else 428 super 429 end 430 end
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 371 def literal_blob_append(sql, v) 372 if v.empty? 373 literal_append(sql, "") 374 else 375 sql << "0x" << v.unpack("H*").first 376 end 377 end
SqlAnywhere uses a preceding X for hex escaping strings
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 361 def literal_false 362 '0' 363 end
Use 0 for false on Sybase
Source
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 356 def literal_true 357 '1' 358 end
Use 1 for true on Sybase
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 380 def multi_insert_sql_strategy 381 :values 382 end
Sybase supports multiple rows in INSERT.
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 385 def requires_emulating_nulls_first? 386 true 387 end
SQLAnywhere does not natively support NULLS FIRST/LAST.
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 389 def select_into_sql(sql) 390 if i = @opts[:into] 391 sql << " INTO " 392 identifier_append(sql, i) 393 end 394 end
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 397 def select_limit_sql(sql) 398 l = @opts[:limit] 399 o = @opts[:offset] 400 if l || o 401 if l 402 sql << " TOP " 403 literal_append(sql, l) 404 else 405 sql << " TOP 2147483647" 406 end 407 408 if o 409 sql << " START AT (" 410 literal_append(sql, o) 411 sql << " + 1)" 412 end 413 end 414 end
Sybase uses TOP N for limit.
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 417 def select_with_sql_base 418 opts[:with].any?{|w| w[:recursive]} ? "WITH RECURSIVE " : super 419 end
Use WITH RECURSIVE instead of WITH if any of the CTEs is recursive
Source
# File lib/sequel/adapters/shared/sqlanywhere.rb 433 def timestamp_precision 434 3 435 end
SQLAnywhere supports millisecond timestamp precision.