Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

stefanneculai
Copy link
Contributor

range_hash method was failing when the key was a Symbol.

@stefanneculai
Copy link
Contributor Author

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 => '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}
Copy link

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.

Copy link
Contributor Author

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.

@luxx
Copy link

luxx commented Aug 21, 2013

this looks good to me

@mattbornski
Copy link

+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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants