[SERVER-8514] $in count query with null array does not yield error on empty collection Created: 11/Feb/13 Updated: 24/Nov/14 Resolved: 14/Nov/14 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | 2.2.0 |
| Fix Version/s: | 2.8.0-rc1 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Daniel Doubrovkine | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | pull-request, query_triage | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
OSX |
||
| Attachments: |
|
| Operating System: | ALL |
| Participants: |
| Description |
|
A count on a collection that exists yields an error on an invalid query. All is good. > db.foos.insert( { bars: [ 1, 2 ]}) A count on a collection that doesn't exist yields 0, which is, IMHO, incorrect. > db.invalid.find({ bars : { $in : null }}).count() This is an odd optimization, I would expect them to fail the same way. |
| Comments |
| Comment by Githook User [ 14/Nov/14 ] | |||||||||
|
Author: {u'username': u'Michael-karn-ivanov', u'name': u'Michael Ivanov', u'email': u'michael.karn.ivanov@gmail.com'}Message: Closes #783 Signed-off-by: Benety Goh <benety@mongodb.com> | |||||||||
| Comment by David Storch [ 18/Sep/14 ] | |||||||||
|
Hi, Thanks very much for submitting Pull Request #780! We have reviewed this change, and unfortunately concluded that it is not the correct approach for addressing this issue. When a namespace does not exist, a count operation should
The correct behavior would look something like this:
The bug is that all versions of MongoDB since 2.2.0 return 0 for the latter case:
With this change, the bug is fixed, but valid count queries against a non-existent collection would also fail. Hopefully this explanation makes sense, and feel free to reach out with any further questions. Best, | |||||||||
| Comment by Aaron Staple [ 07/Mar/13 ] | |||||||||
|
Confirmed that this is still present in 2.2.3. |