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 Sequel’s ruby expression DSL.
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.
A hash of the opposite for each operator symbol, used for inverting objects.
Standard mathematical operators used in NumericMethods
Bitwise mathematical operators used in NumericMethods
Inequality operators used in InequalityMethods
Hash of ruby operator symbols to SQL operators, used in BooleanMethods
Operators that use IN/NOT IN for inclusion/exclusion
Operators that use IS, used for special casing to override literal true/false values
Operator symbols that take exactly two arguments
Operator symbols that take one or more arguments
Operator symbols that take only a single argument
Custom expressions that may have different syntax on different databases
A hash of the opposite for each constant, used for inverting constants.
Set the operator symbol and arguments for this object to the ones given. Convert all args that are hashes or arrays of two element arrays to BooleanExpressions, other than the second arg for an IN/NOT IN operator. 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 180 180: def initialize(op, *args) 181: orig_args = args 182: args = args.map{|a| Sequel.condition_specifier?(a) ? SQL::BooleanExpression.from_value_pairs(a) : a} 183: case op 184: when *N_ARITY_OPERATORS 185: raise(Error, "The #{op} operator requires at least 1 argument") unless args.length >= 1 186: old_args = args 187: args = [] 188: old_args.each{|a| a.is_a?(self.class) && a.op == op ? args.concat(a.args) : args.push(a)} 189: when *TWO_ARITY_OPERATORS 190: raise(Error, "The #{op} operator requires precisely 2 arguments") unless args.length == 2 191: # With IN/NOT IN, even if the second argument is an array of two element arrays, 192: # don't convert it into a boolean expression, since it's definitely being used 193: # as a value list. 194: args[1] = orig_args[1] if IN_OPERATORS.include?(op) 195: when *ONE_ARITY_OPERATORS 196: raise(Error, "The #{op} operator requires a single argument") unless args.length == 1 197: when *CUSTOM_EXPRESSIONS 198: # nothing 199: else 200: raise(Error, "Invalid operator #{op}") 201: end 202: @op = op 203: @args = args 204: end
Return a BooleanExpression with the same op and args.
# File lib/sequel/sql.rb, line 1017 1017: def sql_boolean 1018: BooleanExpression.new(self.op, *self.args) 1019: end
Return a NumericExpression with the same op and args.
# File lib/sequel/sql.rb, line 1022 1022: def sql_number 1023: NumericExpression.new(self.op, *self.args) 1024: end
Return a StringExpression with the same op and args.
# File lib/sequel/sql.rb, line 1027 1027: def sql_string 1028: StringExpression.new(self.op, *self.args) 1029: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.