Skip to content
This repository has been archived by the owner on Sep 27, 2022. It is now read-only.

Commit

Permalink
Merge dd3c2b2 into e605a0b
Browse files Browse the repository at this point in the history
  • Loading branch information
fdegiuli committed Jun 4, 2013
2 parents e605a0b + dd3c2b2 commit de86002
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions lib/fuzzily/searchable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,21 @@ def make_field_fuzzily_searchable(field, options={})

trigram_class.transaction do
batch.each { |record| record.send(trigram_association).delete_all }
trigram_class.connection.insert(%Q{
INSERT INTO `#{trigram_class.table_name}`
(`owner_type`, `owner_id`, `fuzzy_field`, `score`, `trigram`)
VALUES
#{inserts.join(", ")}
})
unless ActiveRecord::Base.connection.instance_of? ActiveRecord::ConnectionAdapters::PostgreSQLAdapter then
trigram_class.connection.insert(%Q{
INSERT INTO `#{trigram_class.table_name}`
(`owner_type`, `owner_id`, `fuzzy_field`, `score`, `trigram`)
VALUES
#{inserts.join(", ")}
})
else #can't use backticks because they're not supported
trigram_class.connection.insert(%Q{
INSERT INTO #{trigram_class.table_name}
(owner_type, owner_id, fuzzy_field, score, trigram)
VALUES
#{inserts.join(", ")}
})
end
end
end
end
Expand Down

0 comments on commit de86002

Please sign in to comment.