Class: ActiveRecord::Refined::Dialect::Mysql

Inherits:
MysqlCompat
  • Object
show all
Defined in:
lib/active_record/refined/dialect/mysql.rb

Overview

MySQL proper, which has a JSON type of its own where MariaDB has only the text.

Constant Summary

Constants inherited from MysqlCompat

ActiveRecord::Refined::Dialect::MysqlCompat::FUNCTIONS

Instance Method Summary collapse

Methods inherited from MysqlCompat

#bit_count, #bitwise_xor, #check_string_aggregate_window, #excluded, #filter_supported?, #full_outer_join_supported?, #grouping_by_with_rollup?, #grouping_supported?, #json_aggregate_filter_supported?, #json_contains, #json_has_key, #json_list_by_element?, #json_path, #string_agg

Instance Method Details

#json_literal(json, _model) ⇒ Object

MySQL has a JSON type, so a Ruby value is cast to it; a bare string beside JSON would be a JSON string, outranking every number.



11
12
13
14
# File 'lib/active_record/refined/dialect/mysql.rb', line 11

def json_literal(json, _model)
  Arel::Nodes::NamedFunction.new(
    "CAST", [Arel::Nodes::As.new(json, Arel::Nodes::SqlLiteral.new("JSON"))])
end