Module | Sequel::SQL::OperatorBuilders |
In: |
lib/sequel/sql.rb
|
This adds methods to create SQL expressions using operators:
Sequel.+(1, :a) # (1 + a) Sequel.-(1, :a) # (1 - a) Sequel.*(1, :a) # (1 * a) Sequel./(1, :a) # (1 / a) Sequel.&(:b, :a) # (b AND a) Sequel.|(:b, :a) # (b OR a)
Return NumericExpression for the exponentiation:
Sequel.**(2, 3) # SQL: power(2, 3)
# File lib/sequel/sql.rb, line 849 849: def **(a, b) 850: SQL::NumericExpression.new(:**, a, b) 851: end
Invert the given expression. Returns a Sequel::SQL::BooleanExpression created from this argument, not matching all of the conditions.
Sequel.~(nil) # SQL: NOT NULL Sequel.~([[:a, true]]) # SQL: a IS NOT TRUE Sequel.~([[:a, 1], [:b, [2, 3]]]) # SQL: a != 1 OR b NOT IN (2, 3)
# File lib/sequel/sql.rb, line 859 859: def ~(arg) 860: if condition_specifier?(arg) 861: SQL::BooleanExpression.from_value_pairs(arg, :OR, true) 862: else 863: SQL::BooleanExpression.invert(arg) 864: end 865: end