lib/thinking_sphinx/search.rb in hawkerb-thinking-sphinx-1.3.15 vs lib/thinking_sphinx/search.rb in hawkerb-thinking-sphinx-1.3.16
- old
+ new
@@ -667,11 +667,11 @@
:all,
:joins => options[:joins],
:conditions => {klass.primary_key_for_sphinx.to_sym => ids},
:include => (options[:include] || index_options[:include]),
:select => (options[:select] || index_options[:select]),
- :order => (options[:sql_order] || index_options[:sql_order])
+ :order => (options[:sql_order] || index_options[:sql_order] || "FIELD(id, #{ids.join(',') })")
) : []
# Raise an exception if we find records in Sphinx but not in the DB, so
# the search method can retry without them. See
# ThinkingSphinx::Search.retry_search_on_stale_index.
@@ -680,16 +680,10 @@
raise StaleIdsException, stale_ids
end
# if the user has specified an SQL order, return the collection
# without rearranging it into the Sphinx order
- return instances if (options[:sql_order] || index_options[:sql_order])
-
- ids.collect { |obj_id|
- instances.detect do |obj|
- obj.primary_key_for_sphinx == obj_id
- end
- }
+ return instances
end
# Group results by class and call #find(:all) once for each group to reduce
# the number of #find's in multi-model searches.
#