[SERVER-15456] relax validation of "query" field in count command for driver backwards compatibility Created: 29/Sep/14  Updated: 12/Aug/15  Resolved: 01/Oct/14

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.7.7
Fix Version/s: 2.7.8

Type: Task Priority: Major - P3
Reporter: David Storch Assignee: David Storch
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-19907 Distinct command should accept a BSON... Closed
related to PHPLIB-91 Ensure query/filter args always seria... Closed
Participants:

 Description   

Commit d71566a55ebbe76ee introduced server-side validation of the "query" field in the count command, rejecting commands where "query" is not of BSON type Object.

Some drivers pass non-Object values for the "query" field in the case that the application did not provide a value. The validation described above can therefore cause compatibility issues for drivers. We should consider relaxing the validation to allow some or all non-Object values.



 Comments   
Comment by Githook User [ 01/Oct/14 ]

Author:

{u'username': u'dstorch', u'name': u'David Storch', u'email': u'david.storch@10gen.com'}

Message: SERVER-15456 relax validation of 'query' field for count command
Branch: master
https://github.com/mongodb/mongo/commit/f4514b50d9c4d8509c6108b2c17d021c2aee7d82

Comment by Jeffrey Yemin [ 29/Sep/14 ]

2.6 is very lenient:

> db.runCommand({count : "test", query : {}} )
{ "n" : 2, "ok" : 1 }
> db.runCommand({count : "test", query : null} )
{ "n" : 2, "ok" : 1 }
> db.runCommand({count : "test", query : 1} )
{ "n" : 2, "ok" : 1 }
> db.runCommand({count : "test", query : false} )
{ "n" : 2, "ok" : 1 }
> db.runCommand({count : "test", query : "f"} )
{ "n" : 2, "ok" : 1 }

Comment by Craig Wilson [ 29/Sep/14 ]

I don't see any relation between null and false. Null means no value, which many languages would interpret, as Gustavo said, as undefined/not present. False means false. It has a value and it means something very specific. This is very different from null in my opinion.

Comment by Gustavo Niemeyer [ 29/Sep/14 ]

The usual none/null/nil values are a common way to spell "undefined" in the respective languages that accept those values, so idioms are created exploring that expectation. I also don't really mind either way, as the Go driver is even fixed to not touch the edge case by now, but it doesn't sound like we should worry about people that expect "false" to work as a query. This is already an error, isn't it?

Comment by Gustavo Niemeyer [ 29/Sep/14 ]

It's worth pointing out that the "non-Object values" that drivers might pass is really just null, meaning undefined, so there's no need to accept completely bogus data.

Generated at Thu Feb 08 03:38:04 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.