Module: Sequel::SQL::NoBooleanInputMethods

Included in:
NumericExpression, StringExpression
Defined in:
lib/sequel_core/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.



225
226
227
228
229
230
231
232
233
# File 'lib/sequel_core/sql.rb', line 225

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