[SERVER-17004] shell should raise a useful error on mixed usage of $query document with .explain() Created: 22/Jan/15 Updated: 24/Jan/15 Resolved: 24/Jan/15 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Shell |
| Affects Version/s: | 2.4.12 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Musti | Assignee: | Matt Kangas |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||
| Operating System: | ALL | |||||||||||||||||||||||||||||||||||||||||||||||||
| Steps To Reproduce: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||
| Participants: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
| Comments |
| Comment by Matt Kangas [ 24/Jan/15 ] | ||||||||
|
Duplicate of | ||||||||
| Comment by David Storch [ 22/Jan/15 ] | ||||||||
|
mustiguel, you're welcome. Let us know if you have any further questions. | ||||||||
| Comment by Musti [ 22/Jan/15 ] | ||||||||
|
Hi David, thank you very much for replying quickly and your explanation. Thx again! | ||||||||
| Comment by David Storch [ 22/Jan/15 ] | ||||||||
|
Hi mustiguel, Thanks for the bug report! The difference between $explain and .explain() is this case is due to unsupported query syntax. Queries must either be issued using the $query syntax in which operators are passed to .find() as $-prefixed fields, or must be issued using chaining syntax. For example, you can search for documents where a is 3, hint on a, and sort by b ascending using the $query syntax like so:
Issuing the same query with chaining looks like this:
Note that the chaining syntax is preferred and should be used whenever possible. If you are using a supported driver, it should have equivalent helpers for things like hint and sort so that you do not have to work with the raw $query document. The query tagged as "query 1" above mixes $query with a chained .explain():
This mixed usage is invalid and should raise an error. Version 2.6.7 raises the following error:
Although this works as designed, I'm going to keep this open as a usability request to make the error message more specific. Best, |