[SERVER-2322] $exists requires true, should also accept 1 Created: 03/Jan/11 Updated: 12/Jul/16 Resolved: 06/Apr/11 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | 1.6.5 |
| Fix Version/s: | 1.9.0 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Roy Smith | Assignee: | Aaron Staple |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Operating System: | ALL | ||||||||
| Participants: | |||||||||
| Description |
|
I would have expected the following two queries to be identical. Apparently, $exists requires an explicit "true". By analogy with the usual query syntax, I would have expected $exits: 1 to be the same as $exists: true, but it appears not to be. I'm not sure if this is a bug, but it certainly does violate the principle of least astonishment. > db.users.find({is_dup_of: {$exists: true}}).count() |
| Comments |
| Comment by Githook User [ 26/Mar/14 ] |
|
Author: {u'username': u'RedBeard0531', u'name': u'Mathias Stearn', u'email': u'mathias@10gen.com'}Message: (cherry picked from commit 5205b62d5c0517a152ce739ab11ec0b3a9cd1859) |
| Comment by Githook User [ 26/Mar/14 ] |
|
Author: {u'username': u'RedBeard0531', u'name': u'Mathias Stearn', u'email': u'mathias@10gen.com'}Message: |
| Comment by auto [ 31/Aug/11 ] |
|
Author: {u'login': u'stbrody', u'name': u'Spencer T Brody', u'email': u'spencer@10gen.com'}Message: Extend tests for $exists accepting 1 and 0 so that the tests can catch |
| Comment by Chris [ 30/Aug/11 ] |
|
+1 this is definitely a DANGEROUS violation of the principle of least astonishment IMHO, and should be fixed! If you use $exists with a .remove() operation, you could end up deleting /everything in your collection except what you are naively trying to remove/ OUCH! |
| Comment by auto [ 05/Apr/11 ] |
|
Author: {u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'}Message: |