lib/searchlogic/named_scopes/conditions.rb in binarylogic-searchlogic-2.1.8 vs lib/searchlogic/named_scopes/conditions.rb in binarylogic-searchlogic-2.1.9

- old
+ new

@@ -138,10 +138,12 @@ end end def create_primary_condition(column, condition) column_type = columns_hash[column.to_s].type + match_keyword = + ActiveRecord::Base.connection.adapter_name == "PostgreSQL" ? "ILIKE" : "LIKE" scope_options = case condition.to_s when /^equals/ scope_options(condition, column_type, "#{table_name}.#{column} = ?") when /^does_not_equal/ scope_options(condition, column_type, "#{table_name}.#{column} != ?") @@ -152,20 +154,20 @@ when /^greater_than_or_equal_to/ scope_options(condition, column_type, "#{table_name}.#{column} >= ?") when /^greater_than/ scope_options(condition, column_type, "#{table_name}.#{column} > ?") when /^like/ - scope_options(condition, column_type, "#{table_name}.#{column} LIKE ?", :like) + scope_options(condition, column_type, "#{table_name}.#{column} #{match_keyword} ?", :like) when /^not_like/ - scope_options(condition, column_type, "#{table_name}.#{column} NOT LIKE ?", :like) + scope_options(condition, column_type, "#{table_name}.#{column} NOT #{match_keyword} ?", :like) when /^begins_with/ - scope_options(condition, column_type, "#{table_name}.#{column} LIKE ?", :begins_with) + scope_options(condition, column_type, "#{table_name}.#{column} #{match_keyword} ?", :begins_with) when /^not_begin_with/ - scope_options(condition, column_type, "#{table_name}.#{column} NOT LIKE ?", :begins_with) + scope_options(condition, column_type, "#{table_name}.#{column} NOT #{match_keyword} ?", :begins_with) when /^ends_with/ - scope_options(condition, column_type, "#{table_name}.#{column} LIKE ?", :ends_with) + scope_options(condition, column_type, "#{table_name}.#{column} #{match_keyword} ?", :ends_with) when /^not_end_with/ - scope_options(condition, column_type, "#{table_name}.#{column} NOT LIKE ?", :ends_with) + scope_options(condition, column_type, "#{table_name}.#{column} NOT #{match_keyword} ?", :ends_with) when "null" {:conditions => "#{table_name}.#{column} IS NULL"} when "not_null" {:conditions => "#{table_name}.#{column} IS NOT NULL"} when "empty"