-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix range_hash sym to string conversion. Add tests. #128
base: master
Are you sure you want to change the base?
Conversation
The new tests added in this commit fail without this fix. It is related to the change from PR #124 |
@@ -50,7 +50,8 @@ | |||
@chain.query = {:name => 'Josh', :email => '[email protected]'} | |||
@chain.send(:index_query).should == {:hash_value => '[email protected]'} | |||
|
|||
@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} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only that for the tests it has to be called this way because it writes it directly on the query object. When you use Model.where("created_at.gt" => 'whatever') it will make "created_at.gt" symbol in the where method. No one said that it has to be sym when people use them.
this looks good to me |
+1 range queries are really challenging with the symbol/string confusion in this ORM |
range_hash method was failing when the key was a Symbol.