Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: karmi/retire
...
head fork: victorsandspoils/tire
compare: master
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Commits on Sep 15, 2011
@szehnder szehnder Fixing an issue where the find method would break when you pass it an…
… array of ids (that were retrieved from a elasticsearch query) that were a super-set of the ids in the project database.

In other words, Imagine an elastic search index for an entity called a User.

User.search('foo', :load => true).collect(&:id)
["1", "2", "3", "4"]

User.search('foo', :load => true).results
Error -- if your rails database only has ["1", "3"]

-----
this is because of a difference in how find() responds to a super-set array compared with the where() ActiveRecord method.
72ce639
Commits on Dec 16, 2011
@szehnder szehnder Merge remote-tracking branch 'karmi/master' 6a7cf7e
Showing with 2 additions and 2 deletions.
  1. +1 −1  lib/tire/model/search.rb
  2. +1 −1  lib/tire/results/collection.rb
View
2  lib/tire/model/search.rb
@@ -179,7 +179,7 @@ module Loader
# for the search method.
#
def load(options=nil)
- options ? self.class.find(self.id, options) : self.class.find(self.id)
+ options ? self.class.where(:id => self.id).where(options) : self.class.where(:id => self.id)
end
end
View
2  lib/tire/results/collection.rb
@@ -54,7 +54,7 @@ def results
end
ids = @response['hits']['hits'].map { |h| h['_id'] }
- records = @options[:load] === true ? klass.find(ids) : klass.find(ids, @options[:load])
+ records = @options[:load] === true ? klass.where(:id => ids) : klass.where(:id => ids).where(@options[:load])
# Reorder records to preserve order from search results
ids.map { |id| records.detect { |record| record.id.to_s == id.to_s } }

No commit comments for this range

Something went wrong with that request. Please try again.