Sha256: 90109704e0da4873b16cdd451e484cb2a1267fa67c96cf0ff60e3ecc31a16005

Contents?: true

Size: 734 Bytes

Versions: 4

Compression:

Stored size: 734 Bytes

Contents

module Searchgasm
  module Condition
    class IsNil < Base
      self.ignore_blanks = false
      self.type_cast_value = false
      
      class << self
        def aliases_for_column(column)
          ["#{column.name}_nil", "#{column.name}_is_null", "#{column.name}_null"]
        end
      end
      
      def to_conditions(value)
        # Some databases handle null values differently, let AR handle this
        if value == true || value == "true" || value == 1 || value == "1"
          "#{quoted_table_name}.#{quoted_column_name} is NULL"
        elsif value == false || value == "false" || value == 0 || value == "0"
          "#{quoted_table_name}.#{quoted_column_name} is NOT NULL"
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
searchgasm-1.1.2 lib/searchgasm/condition/is_nil.rb
searchgasm-1.1.3 lib/searchgasm/condition/is_nil.rb
searchgasm-1.2.0 lib/searchgasm/condition/is_nil.rb
searchgasm-1.2.1 lib/searchgasm/condition/is_nil.rb