Class: ActiveRecord::Refined::Dialect::MysqlCompat
- Inherits:
-
Dialect
- Object
- Dialect
- ActiveRecord::Refined::Dialect::MysqlCompat
- Defined in:
- lib/active_record/refined/dialect/mysql_compat.rb
Overview
What MySQL and MariaDB share, which is most of it; the two part company only in the Mysql and Mariadb subclasses.
Constant Summary collapse
- FUNCTIONS =
{ trunc: "TRUNCATE", date_trunc: nil, format: nil }.freeze
Instance Method Summary collapse
- #bit_count(expr, _model) ⇒ Object
- #bitwise_xor(left, right) ⇒ Object
- #check_string_aggregate_window(model) ⇒ Object
-
#excluded(column, model) ⇒ Object
The excluded row is VALUES(column), which takes the column bare.
- #filter_supported? ⇒ Boolean
- #full_outer_join_supported? ⇒ Boolean
- #grouping_by_with_rollup? ⇒ Boolean
- #grouping_supported?(kind) ⇒ Boolean
- #json_aggregate_filter_supported? ⇒ Boolean
- #json_contains(document, json, _model) ⇒ Object
- #json_has_key(document, _name, path, _model) ⇒ Object
- #json_list_by_element? ⇒ Boolean
- #json_path(document, dollar_path, _steps, json_value, _model) ⇒ Object
-
#string_agg(operand, separator, orders, _string, model) ⇒ Object
GROUP_CONCAT, its separator a keyword after the operand and after the ORDER BY when there is one.
Instance Method Details
#bit_count(expr, _model) ⇒ Object
14 15 16 |
# File 'lib/active_record/refined/dialect/mysql_compat.rb', line 14 def bit_count(expr, _model) AST::Function.new("BIT_COUNT", [expr]) end |
#bitwise_xor(left, right) ⇒ Object
24 25 26 |
# File 'lib/active_record/refined/dialect/mysql_compat.rb', line 24 def bitwise_xor(left, right) Arel::Nodes::BitwiseXor.new(left, right) end |
#check_string_aggregate_window(model) ⇒ Object
54 55 56 57 |
# File 'lib/active_record/refined/dialect/mysql_compat.rb', line 54 def check_string_aggregate_window(model) raise NotImplementedError, "string_agg over a window has no equivalent on #{model.connection_db_config.adapter}" end |
#excluded(column, model) ⇒ Object
The excluded row is VALUES(column), which takes the column bare.
19 20 21 22 |
# File 'lib/active_record/refined/dialect/mysql_compat.rb', line 19 def excluded(column, model) quoted = model.with_connection { |connection| connection.quote_column_name(column) } AST::Function.new("VALUES", [Arel::Nodes::SqlLiteral.new(quoted)]) end |
#filter_supported? ⇒ Boolean
12 |
# File 'lib/active_record/refined/dialect/mysql_compat.rb', line 12 def filter_supported? = false |
#full_outer_join_supported? ⇒ Boolean
11 |
# File 'lib/active_record/refined/dialect/mysql_compat.rb', line 11 def full_outer_join_supported? = false |
#grouping_by_with_rollup? ⇒ Boolean
63 |
# File 'lib/active_record/refined/dialect/mysql_compat.rb', line 63 def grouping_by_with_rollup? = true |
#grouping_supported?(kind) ⇒ Boolean
61 |
# File 'lib/active_record/refined/dialect/mysql_compat.rb', line 61 def grouping_supported?(kind) = kind == :rollup |
#json_aggregate_filter_supported? ⇒ Boolean
44 |
# File 'lib/active_record/refined/dialect/mysql_compat.rb', line 44 def json_aggregate_filter_supported? = false |
#json_contains(document, json, _model) ⇒ Object
35 36 37 |
# File 'lib/active_record/refined/dialect/mysql_compat.rb', line 35 def json_contains(document, json, _model) Arel::Nodes::NamedFunction.new("JSON_CONTAINS", [document, json]) end |
#json_has_key(document, _name, path, _model) ⇒ Object
39 40 41 42 |
# File 'lib/active_record/refined/dialect/mysql_compat.rb', line 39 def json_has_key(document, _name, path, _model) Arel::Nodes::NamedFunction.new( "JSON_CONTAINS_PATH", [document, Arel::Nodes.build_quoted("one"), path]) end |
#json_list_by_element? ⇒ Boolean
59 |
# File 'lib/active_record/refined/dialect/mysql_compat.rb', line 59 def json_list_by_element? = true |
#json_path(document, dollar_path, _steps, json_value, _model) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/active_record/refined/dialect/mysql_compat.rb', line 28 def json_path(document, dollar_path, _steps, json_value, _model) extracted = Arel::Nodes::NamedFunction.new( "JSON_EXTRACT", [document, Arel::Nodes.build_quoted(dollar_path)]) return extracted if json_value Arel::Nodes::NamedFunction.new("JSON_UNQUOTE", [extracted]) end |
#string_agg(operand, separator, orders, _string, model) ⇒ Object
GROUP_CONCAT, its separator a keyword after the operand and after the ORDER BY when there is one.
48 49 50 51 52 |
# File 'lib/active_record/refined/dialect/mysql_compat.rb', line 48 def string_agg(operand, separator, orders, _string, model) order = orders.empty? ? "" : " ORDER BY #{compile_list(orders, model)}" Arel.sql("GROUP_CONCAT(#{compile(operand, model)}#{order} " \ "SEPARATOR #{quote(separator, model)})") end |