[CDRIVER-468] mongoc_collection_find and logical $and/$or Created: 22/Nov/14 Updated: 03/May/17 Resolved: 27/Jan/15 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | None |
| Affects Version/s: | 1.1.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | John Myers | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
*nix |
||
| Issue Links: |
|
||||
| Description |
|
When construction a query using BCON_NEW, using the $and or $or operator will fail if there is another expression prior to the use of $and/$or. The following query will yield results: The following will NOT yield results: query = BCON_NEW(GROUPAUTO, BCON_BOOL(true), "$and","[","{",GROUPSTART,"{","$lte",BCON_INT32(addr),"} ","}","{",GROUPSTOP," {","$gte",BCON_INT32(addr),"}","}","]"); If I call a bson_as_json on the second query, and use that json to create a raw query from the shell. It WILL yield results. |
| Comments |
| Comment by Mira Carey [ 12/Jan/15 ] |
|
Unfortunately the C driver has some overly aggressive validation for queries. From the specification for the wire protocol (which find thinly wraps):
Those are all viable top level $-prefixed keys that change the behavior of query. You can "escape" your query by creating a nested subdocument under a $query key. Hope that helps, |
| Comment by John Myers [ 22/Nov/14 ] |
|
Actually, it looks like combining an $and or $or expression with any other expression, will not work with the C driver. |
| Comment by John Myers [ 22/Nov/14 ] |
|
This is the output from the failed C query that does work in the shell: }, { "stop_ip_int" : { "$gte" : 168428850 }} ] } I am also aware that I could omit the $and since it is implicit if I just use the three expressions. But I was testing something else and inadvertently found this. |