Represents a complex SQL expression, with a given operator and one or more attributes (which may also be ComplexExpressions, forming a tree). This class is the backbone of the blockless filter support in Sequel.
This is an abstract class that is not that useful by itself. The subclasses BooleanExpression, NumericExpression, and StringExpression define the behavior of the DSL via operators.
Bitwise Mathematical Operators used in NumericMethods
Hash of ruby operator symbols to SQL operators, used in BooleanMethods
Inequality Operators used in InequalityMethods
Operators that use IS, used for special casing to override literal true/false values
Standard Mathematical Operators used in NumericMethods
Operator symbols that take one or more arguments
Operator symbols that take one argument
A hash of the opposite for each operator symbol, used for inverting objects.
Operator symbols that take exactly two arguments
Set the operator symbol and arguments for this object to the ones given. Convert all args that are hashes or arrays with all two pairs to BooleanExpressions. Raise an error if the operator doesn’t allow boolean input and a boolean argument is given. Raise an error if the wrong number of arguments for a given operator is used.
# File lib/sequel/sql.rb, line 153 def initialize(op, *args) args.map!{|a| Sequel.condition_specifier?(a) ? SQL::BooleanExpression.from_value_pairs(a) : a} case op when *N_ARITY_OPERATORS raise(Error, "The #{op} operator requires at least 1 argument") unless args.length >= 1 old_args = args args = [] old_args.each{|a| a.is_a?(self.class) && a.op == op ? args.concat(a.args) : args.push(a)} when *TWO_ARITY_OPERATORS raise(Error, "The #{op} operator requires precisely 2 arguments") unless args.length == 2 when *ONE_ARITY_OPERATORS raise(Error, "The #{op} operator requires a single argument") unless args.length == 1 else raise(Error, "Invalid operator #{op}") end @op = op @args = args end
Generated with the Darkfish Rdoc Generator 2.