Class: Babik::Selection::Operation::IfNotNullOperation
- Defined in:
- lib/babik/queryset/lib/selection/operation/operations.rb
Overview
Operations that in case a nil is passed will convert the equality comparison to IS NULL
Constant Summary collapse
- SQL_OPERATOR =
'='
Instance Attribute Summary
Attributes inherited from Base
#field, #sql_operation, #sql_operation_template, #value
Instance Method Summary collapse
-
#initialize(field, value) ⇒ IfNotNullOperation
constructor
A new instance of IfNotNullOperation.
Methods inherited from Base
#_init_sql_operation, date_special_cases, #db_engine, escape, factory, initialize_operation, initialize_operators, operator?, special_cases, #to_s
Constructor Details
#initialize(field, value) ⇒ IfNotNullOperation
Returns a new instance of IfNotNullOperation.
20 21 22 23 24 25 26 |
# File 'lib/babik/queryset/lib/selection/operation/operations.rb', line 20 def initialize(field, value) if value.nil? super(field, '?field IS NULL', value) else super(field, "?field #{SQL_OPERATOR} ?value", value) end end |