Skip to content

Commit

Permalink
Remove Spree::LIKE definition, as it is only used one place in all th…
Browse files Browse the repository at this point in the history
…e code
  • Loading branch information
radar committed Sep 10, 2013
1 parent 7de7fcd commit fe77e9c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 3 additions & 1 deletion core/app/models/spree/product.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ def categorise_variants_from_option(opt_type)
end

def self.like_any(fields, values)
where_str = fields.map { |field| Array.new(values.size, "#{self.quoted_table_name}.#{field} #{LIKE} ?").join(' OR ') }.join(' OR ')
# PostgreSQL is case sensitive, so we need to use ILIKE to work around that.
like = ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' ? 'ILIKE' : 'LIKE'
where_str = fields.map { |field| Array.new(values.size, "#{self.quoted_table_name}.#{field} #{like} ?").join(' OR ') }.join(' OR ')
self.where([where_str, values.map { |value| "%#{value}%" } * fields.size].flatten)
end

Expand Down
5 changes: 0 additions & 5 deletions core/config/initializers/spree.rb

This file was deleted.

0 comments on commit fe77e9c

Please sign in to comment.