Module: Sequel::SQL::NoBooleanInputMethods

Included in:
NumericExpression, StringExpression
Defined in:
lib/sequel/lib/sequel/sql.rb

Overview

This module augments the default initalize method for the ComplexExpression subclass it is included in, so that attempting to use boolean input when initializing a NumericExpression or StringExpression results in an error.

Instance Method Summary collapse

Instance Method Details

#initialize(op, *args) ⇒ Object

Raise an Error if one of the args would be boolean in an SQL context, otherwise call super.


278
279
280
281
282
283
284
285
286
# File 'lib/sequel/lib/sequel/sql.rb', line 278

def initialize(op, *args)
  args.each do |a|
    case a
    when BooleanExpression, TrueClass, FalseClass, NilClass, Hash, Array
      raise(Error, "cannot apply #{op} to a boolean expression")
    end
  end
  super
end