Class: Sequel::Sqljs::Dataset
- Inherits:
-
Dataset
- Object
- Dataset
- Sequel::Sqljs::Dataset
- Includes:
- DatasetMethods
- Defined in:
- lib/bormashino_sequel_sqljs_adapter/sqljs.rb
Defined Under Namespace
Modules: ArgumentMapper
Constant Summary collapse
- BindArgumentMethods =
prepared_statements_module(:bind, ArgumentMapper)
- PreparedStatementMethods =
prepared_statements_module(:prepare, BindArgumentMethods)
Constants included from DatasetMethods
Sequel::Sqljs::DatasetMethods::CONSTANT_MAP, Sequel::Sqljs::DatasetMethods::EXTRACT_MAP, Sequel::Sqljs::DatasetMethods::INSERT_CONFLICT_RESOLUTIONS
Instance Method Summary collapse
-
#complex_expression_sql_append(sql, op, args) ⇒ Object
Support regexp functions if using :setup_regexp_function Database option.
- #fetch_rows(sql) ⇒ Object
-
#supports_regexp? ⇒ Boolean
Support regexp if using :setup_regexp_function Database option.
Methods included from DatasetMethods
#cast_sql_append, #constant_sql_append, #delete, #explain, #having, #insert_conflict, #insert_ignore, #insert_select, #insert_select_sql, #quoted_identifier_append, #returning, #select, #supports_cte?, #supports_cte_in_subqueries?, #supports_deleting_joins?, #supports_derived_column_lists?, #supports_intersect_except_all?, #supports_is_true?, #supports_modifying_joins?, #supports_multiple_column_in?, #supports_returning?, #supports_timestamp_timezones?, #supports_where_true?, #supports_window_clause?, #supports_window_function_frame_option?, #supports_window_functions?
Instance Method Details
#complex_expression_sql_append(sql, op, args) ⇒ Object
Support regexp functions if using :setup_regexp_function Database option.
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 |
# File 'lib/bormashino_sequel_sqljs_adapter/sqljs.rb', line 379 def complex_expression_sql_append(sql, op, args) case op when :~, :!~, :'~*', :'!~*' return super unless supports_regexp? case_insensitive = %i[~* !~*].include?(op) sql << 'NOT ' if %i[!~ !~*].include?(op) sql << '(' sql << 'LOWER(' if case_insensitive literal_append(sql, args[0]) sql << ')' if case_insensitive sql << ' REGEXP ' sql << 'LOWER(' if case_insensitive literal_append(sql, args[1]) sql << ')' if case_insensitive sql << ')' else super end end |
#fetch_rows(sql) ⇒ Object
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 |
# File 'lib/bormashino_sequel_sqljs_adapter/sqljs.rb', line 400 def fetch_rows(sql, &) execute(sql) do |result| columns = result[:columns].map(&:to_sym) type_procs = if types = result[:types] cps = db.conversion_procs columns.map { |n| types[n.to_s] }.map { |t| cps[base_type_name(t)] } end result[:result].each do |r| r['values'].map do |values| values.map.with_index do |v, i| value = if type_procs && type_proc = type_procs[i] type_proc.call(v) else v end [columns[i].to_sym, value] end.to_h end.each(&) end self.columns = columns end end |
#supports_regexp? ⇒ Boolean
Support regexp if using :setup_regexp_function Database option.
427 428 429 |
# File 'lib/bormashino_sequel_sqljs_adapter/sqljs.rb', line 427 def supports_regexp? db.allow_regexp? end |