[JAVA-1828] Filters.and methods should handle zero clauses correctly Created: 21/May/15  Updated: 28/May/15  Resolved: 28/May/15

Status: Closed
Project: Java Driver
Component/s: API, Query Operations
Affects Version/s: 3.0.1
Fix Version/s: 3.0.2, 3.1.0

Type: Improvement Priority: Minor - P4
Reporter: Robert Stam Assignee: Jeffrey Yemin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

The Filters builder 'and' and 'or' methods should handle empty lists of clauses by rendering them to $and and $or operators with empty arrays:

Filters.and(emptyList()) => "{ $and : [ ] }"
Filters.or(emptyList()) => "{ $or : [ ] }"

It is not really obvious what semantics And and Or should have when the list of clauses is empty. By rendering them this way we leave it up to the server to decide. The server currently returns error messages for both of these, but it might conceivably support them in the future.



 Comments   
Comment by Jeffrey Yemin [ 28/May/15 ]

Released in 3.0.2.

Comment by Githook User [ 28/May/15 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: Render Filters.and as {$and : [] } if the list of filters is empty. That way, the driver leaves it to the server to decide the meaning of an empty array for both $and and $or operators, which currently is to return an error.

JAVA-1828
Branch: 3.0.x
https://github.com/mongodb/mongo-java-driver/commit/71573337d7bf1d870b9c060fd12364c98a4471e9

Comment by Githook User [ 28/May/15 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: Render Filters.and as {$and : [] } if the list of filters is empty. That way, the driver leaves it to the server to decide the meaning of an empty array for both $and and $or operators, which currently is to return an error.

JAVA-1828
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/2ca78c7f0a89ff0657c02608462347af6c203efa

Generated at Thu Feb 08 08:55:36 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.