lib/searchlogic/named_scopes/column_conditions.rb in searchlogic-2.5.1 vs lib/searchlogic/named_scopes/column_conditions.rb in searchlogic-2.5.2

- old
+ new

@@ -157,15 +157,17 @@ # This method helps cut down on defining scope options for conditions that allow *_any or *_all conditions. # Kepp in mind that the lambdas get cached in a method, so you want to keep the contents of the lambdas as # fast as possible, which is why I didn't do the case statement inside of the lambda. def scope_options(condition, column, sql, options = {}) + equals = !(condition.to_s =~ /^equals/).nil? + does_not_equal = !(condition.to_s =~ /^does_not_equal/).nil? + case condition.to_s when /_(any|all)$/ any = $1 == "any" join_word = any ? " OR " : " AND " - equals = condition.to_s =~ /^equals_/ searchlogic_lambda(column.type, :skip_conversion => options[:skip_conversion]) { |*values| unless values.empty? if equals && any has_nil = values.include?(nil) values = values.flatten.compact @@ -191,9 +193,15 @@ end } else searchlogic_lambda(column.type, :skip_conversion => options[:skip_conversion]) { |*values| values.collect! { |value| value_with_modifier(value, options[:value_modifier]) } + + if does_not_equal && values == [nil] + sql.gsub!('!=', 'IS NOT') + elsif equals && values == [nil] + sql.gsub!('=', 'IS') + end {:conditions => [sql, *values]} } end end \ No newline at end of file