Fix range_hash sym to string conversion. Add tests. #128

Open
wants to merge 3 commits into from

3 participants

@stefanneculai

range_hash method was failing when the key was a Symbol.

@stefanneculai

The new tests added in this commit fail without this fix. It is related to the change from PR #124

@luxx luxx commented on the diff Jul 8, 2013
spec/dynamoid/criteria/chain_spec.rb
@@ -50,7 +50,8 @@
@chain.query = {:name => 'Josh', :email => 'josh@joshsymonds.com'}
@chain.send(:index_query).should == {:hash_value => 'josh@joshsymonds.com.Josh'}
- @chain.query = {:name => 'Josh', 'created_at.gt' => @time}
+ # All keys are converted to_sym in the where method, so we should pass them in query as Symbols.
+ @chain.query = {:name => 'Josh', 'created_at.gt'.to_sym => @time}
@luxx
luxx added a note Jul 8, 2013

While passing 'name' as symbol instead of a string seems natural, "created_at.gt" seems like an extra burden on the caller. I would expect most people would just call it with "created_at.gt" in string form, which is probably what the test should express.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@luxx

this looks good to me

@mattbornski

+1 range queries are really challenging with the symbol/string confusion in this ORM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment