-
Notifications
You must be signed in to change notification settings - Fork 533
RUBY-1006 Refactor View and Readable to allow for arbtirary query modifiers #677
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
Conversation
spec/mongo/collection/view_spec.rb
Outdated
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.
@behackett I'm assuming that if you provide a $query doc in the selector, it'll use that as the selector, not whatever else is in there. I.e., in this case, { a: 1 } is the selector, not { b: 2 }
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.
@behackett If you have a $query in modifiers, does that get used instead of the selector?
for example:
coll.find({ a: 1 }, { :modifiers => { :$query => { b: 2 } } )
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.
In PyMongo we don't do anything to try to correct that mistake. Since the options in modifiers are added to the criteria after the criteria is changed to {'$query': {'a': 1}} the query ends up being {'$query': {'b': 2}}.
fa17f05 to
314e644
Compare
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.
This should be:
sel = BSON::Document.new(:$query => selector).merge(modifiers)In order to get the indifferent access provided by a BSON::Document vs. a normal hash, also, the command monitoring spec guarantees the filter will also be a BSON::Document.
|
Line 261 of document[:filter] = filter[:$query] ? filter[:$query] : filter |
|
ah, thanks. |
|
Yeah to be on the safe side I would initialize that as a |
RUBY-1006 Refactor View and Readable to allow for arbtirary query modifiers
No description provided.