Permalink
Browse files

let MySQL do the ordering for us (will also suppress out of sync errors)

  • Loading branch information...
1 parent 667f9ec commit 6f39eb96109202b98f57e24688dce62dc1c9f0d5 @schoefmann committed Sep 1, 2009
Showing with 7 additions and 2 deletions.
  1. +1 −1 lib/acts_as_solr/instance.rb
  2. +6 −1 lib/acts_as_solr/parser_methods.rb
View
2 lib/acts_as_solr/instance.rb
@@ -55,7 +55,7 @@ def to_solr_doc
end
def indexing_disabled?
- evaluate_condition(:offline, object) || !evaluate_condition(:if, object)
+ evaluate_condition(:offline, object)
end
def save
View
7 lib/acts_as_solr/parser_methods.rb
@@ -82,7 +82,12 @@ def find_objects(ids, options, configuration)
conditions = [ "#{self.table_name}.#{primary_key} in (?)", ids ]
find_options = {:conditions => conditions}
find_options[:include] = options[:include] if options[:include]
- result = reorder(self.find(:all, find_options), ids)
+ if self.connection.adapter_name =~ /mysql/i
+ find_options[:order] = "FIELD(#{self.table_name}.#{primary_key}, #{ids.join(',')})"
+ result = self.find(:all, find_options)
+ else
+ result = reorder(self.find(:all, find_options), ids)
+ end
else
ids
end

0 comments on commit 6f39eb9

Please sign in to comment.