Bitwise mathematical operators used in NumericMethods
Hash of ruby operator symbols to SQL operators, used in BooleanMethods
A hash of the opposite for each constant, used for inverting constants.
Custom expressions that may have different syntax on different databases
Operators that check for equality
Inequality operators used in InequalityMethods
Operators that use IN/NOT IN for inclusion/exclusion
Operators that use IS, used for special casing to override literal true/false values
Operators that do pattern matching via LIKE
Standard mathematical operators used in NumericMethods
Operator symbols that take one or more arguments
Operator symbols that take only a single argument
A hash of the opposite for each operator symbol, used for inverting objects.
Operators that do pattern matching via regular expressions
Operator symbols that take exactly two arguments
An array of args for this object
The operator symbol for this object
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 213 def initialize(op, *args) orig_args = args 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.map{|a| a.is_a?(self.class) && a.op == :NOOP ? a.args.first : a} 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 # With IN/NOT IN, even if the second argument is an array of two element arrays, # don't convert it into a boolean expression, since it's definitely being used # as a value list. args[1] = orig_args[1] if IN_OPERATORS.include?(op) when *ONE_ARITY_OPERATORS raise(Error, "The #{op} operator requires a single argument") unless args.length == 1 when *CUSTOM_EXPRESSIONS # nothing else raise(Error, "Invalid operator #{op}") end @op = op @args = args end
Return a BooleanExpression with the same op and args.
# File lib/sequel/sql.rb, line 1184 def sql_boolean BooleanExpression.new(self.op, *self.args) end
Return a NumericExpression with the same op and args.
# File lib/sequel/sql.rb, line 1189 def sql_number NumericExpression.new(self.op, *self.args) end
Return a StringExpression with the same op and args.
# File lib/sequel/sql.rb, line 1194 def sql_string StringExpression.new(self.op, *self.args) end
ComplexExpression's initializer uses a splat for the operator arguments.
# File lib/sequel/extensions/eval_inspect.rb, line 98 def inspect_args [:op, "*args"] end