module Rotor::SQL
SQL functions a query's block may call, which the translator knows by
name: Rotor::SQL.like(name, "A%") is "name" LIKE $1. Called
outside a query they compute the same (a like pattern's % and _,
case folding), so a block keeps its meaning wherever it runs.
/home/runner/work/rotor/rotor/src/sql.qz:5
Classes and modules
Rotor::SQL::RawSQL written as is where a migration takes a value: a column's default that is not a literal (Rotor::SQL.raw("now()")).
Class methods
def self.like(s: String, pattern: String) -> Bool
Whether s matches the LIKE pattern: % any run of characters,
_ one, \ escaping the next.
Rotor::SQL.like("Ann", "A%") # => true
Rotor::SQL.like("Ann", "a%") # => false
def self.ilike(s: String, pattern: String) -> Bool
like with case folded: SQL's ILIKE.
def self.not_nil[T](c: T?) -> T
c, which is not nil: in a query's block, a nullable column where
the condition before it says it is not NULL (where { !age.nil? && Rotor::SQL.not_nil(age) > 18 }), translated as the column itself (a
block cannot narrow a getter's result: age is an Int? there).
Refused where nothing says so. Raises ArgumentError on nil.
age: Int? = 3
Rotor::SQL.not_nil(age) # => 3
def self.raw(sql: String) -> Rotor::SQL::Raw
sql as is: a Rotor::SQL::Raw.
Rotor::SQL.raw("now()").sql # => "now()"
def self.lower(s: String) -> String
s in lower case: SQL's lower.
def self.upper(s: String) -> String
s in upper case: SQL's upper.
def self.escape_like(s: String) -> String
The escaped LIKE pattern that matches s itself.
Rotor::SQL.escape_like("50%_off") # => "50\\%\\_off"