Module: ActiveRecord::Refined::AST::JsonComparable
- Included in:
- JsonAggregate, JsonBuild, JsonExcept, JsonKeys, JsonPath, JsonSet
- Defined in:
- lib/active_record/refined/ast.rb
Overview
What a dug value may be compared with. dig_text gives text on every
adapter, and what a text value compared with a number means is a
question the three answer three ways: dig_text(:n) == 5 is true on
SQLite, an error on PostgreSQL and true on MySQL, while
dig_text(:flag) == true is true, an error, and false. cast is what
says which type was meant, and then all three agree.
dig, bury and except give JSON, and a JSON comparison belongs to the JSON types -- jsonb and MySQL's -- where numbers compare as numbers and documents structurally, key order and spelling aside. The Ruby value goes in as a JSON literal, and the adapters without such a type refuse it from JsonLiteral when the SQL is written, which is when the adapter is known.
A string against dig_text, and anything the block itself built -- a column, a function, another dug value -- go through untouched.
Arithmetic and the bit operators are refused outright on both sides:
dig_text(:n) + 1 is 6 on SQLite, an error on PostgreSQL and 6.0 on
MariaDB, and an expression on the right does not change what the
dug side is.
Instance Method Summary collapse
- #between?(min, max) ⇒ Boolean
- #bitwise_not ⇒ Object
- #in?(values) ⇒ Boolean
- #not_between?(min, max) ⇒ Boolean
- #not_in?(values) ⇒ Boolean
- #~ ⇒ Object
Instance Method Details
#between?(min, max) ⇒ Boolean
1013 |
# File 'lib/active_record/refined/ast.rb', line 1013 def between?(min, max) = super(comparison_value(min), comparison_value(max)) |
#bitwise_not ⇒ Object
1026 1027 1028 |
# File 'lib/active_record/refined/ast.rb', line 1026 def bitwise_not raise ArgumentError, arithmetic_refusal(:bitwise_not) end |
#in?(values) ⇒ Boolean
1011 |
# File 'lib/active_record/refined/ast.rb', line 1011 def in?(values) = super(comparison_set(values)) |
#not_between?(min, max) ⇒ Boolean
1014 |
# File 'lib/active_record/refined/ast.rb', line 1014 def not_between?(min, max) = super(comparison_value(min), comparison_value(max)) |
#not_in?(values) ⇒ Boolean
1012 |
# File 'lib/active_record/refined/ast.rb', line 1012 def not_in?(values) = super(comparison_set(values)) |
#~ ⇒ Object
1022 1023 1024 |
# File 'lib/active_record/refined/ast.rb', line 1022 def ~ raise ArgumentError, arithmetic_refusal(:~) end |