Sha256: 4579f7756e1260b02a31fe4e45ba4ed03f680f9f8b6fff1fbc726d0f19d7bb12

Contents?: true

Size: 669 Bytes

Versions: 1

Compression:

Stored size: 669 Bytes

Contents

module Searchgasm
  module Condition
    class Blank < Base
      self.type_cast_sql_type = "boolean"
      
      class << self
        def aliases_for_column(column)
          ["#{column.name}_is_blank"]
        end
      end
      
      def to_conditions(value)
        # Some databases handle null values differently, let AR handle this
        if value == true
          "#{quoted_table_name}.#{quoted_column_name} is NULL or #{quoted_table_name}.#{quoted_column_name} = ''"
        elsif value == false
          "#{quoted_table_name}.#{quoted_column_name} is NOT NULL and #{quoted_table_name}.#{quoted_column_name} != ''"
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
searchgasm-1.2.2 lib/searchgasm/condition/blank.rb