module Rotor::Compare
The comparisons a query's block may write on a nullable column:
User.where { age > 18 } with age an Int?. Every query block
(where, filter, a join's condition, order, update, preload,
select) is checked with using Rotor::Compare (Quarz's docs/01 §7),
so nil compares false there, as SQL's NULL acts in a condition; the
translator gives them SQL's comparison, which can be NULL, and refuses
them where NULL and false differ (under !, as a value). Outside
query blocks Int? > Int is still a type error. Only <, <=, >
and >=: nil has no arithmetic, and ==/!= are Quarz's own.
class CUser < Rotor::Model
table "users" do
column :id, Int, primary: true
column :age, Int, null: true
end
end
CUser.where { age > 18 }.to_sql # => ["SELECT \"id\", \"age\" FROM \"users\" WHERE \"age\" > 18", []]
CUser.where { !(age > 18) } # raises Rotor::UntranslatableError
/home/runner/work/rotor/rotor/src/compare.qz:22
Extensions
def <(other: Object) -> Bool
in extension Nil
def <=(other: Object) -> Bool
in extension Nil
def >(other: Object) -> Bool
in extension Nil
def >=(other: Object) -> Bool
in extension Nil
def <(other: Int | Float | Nil) -> Bool
in extension Int
Whether the receiver is less than other.
from Comparable
def <=(other: Int | Float | Nil) -> Bool
in extension Int
Whether the receiver is less than or equal to other.
from Comparable
def >(other: Int | Float | Nil) -> Bool
in extension Int
Whether the receiver is greater than other.
from Comparable
def >=(other: Int | Float | Nil) -> Bool
in extension Int
Whether the receiver is greater than or equal to other.
from Comparable
def <(other: Int | Float | Nil) -> Bool
in extension Float
Whether the receiver is less than other.
from Comparable
def <=(other: Int | Float | Nil) -> Bool
in extension Float
Whether the receiver is less than or equal to other.
from Comparable
def >(other: Int | Float | Nil) -> Bool
in extension Float
Whether the receiver is greater than other.
from Comparable
def >=(other: Int | Float | Nil) -> Bool
in extension Float
Whether the receiver is greater than or equal to other.
from Comparable
def <(other: String?) -> Bool
in extension String
Whether the receiver is less than other.
from Comparable
def <=(other: String?) -> Bool
in extension String
Whether the receiver is less than or equal to other.
from Comparable
def >(other: String?) -> Bool
in extension String
Whether the receiver is greater than other.
from Comparable
def >=(other: String?) -> Bool
in extension String
Whether the receiver is greater than or equal to other.
from Comparable
def <(other: Time?) -> Bool
in extension Time
Whether the receiver is less than other.
from Comparable
def <=(other: Time?) -> Bool
in extension Time
Whether the receiver is less than or equal to other.
from Comparable
def >(other: Time?) -> Bool
in extension Time
Whether the receiver is greater than other.
from Comparable
def >=(other: Time?) -> Bool
in extension Time
Whether the receiver is greater than or equal to other.
from Comparable