[JAVA-3346] Delete query is systematically created with a "limit" parameter Created: 04/Jul/19 Updated: 27/Oct/23 Resolved: 16/Jul/19 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Query Operations |
| Affects Version/s: | 3.6.4 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Debeissat Nicolas | Assignee: | Ross Lawley |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Description |
|
Hello The delete requests are created with a "limit" parameter and mongodb does not accept it : db.domainevents.deleteMany( { aggregateIdentifier: "2f13501d-6199-425d-899f-cbd51488ec24", limit: "0" }) The following code : systematically adds limit parameter in the request : writer.writeInt32("limit", deleteRequest.isMulti() ? 0 : 1);
Thanks for mongodb |
| Comments |
| Comment by Debeissat Nicolas [ 16/Jul/19 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Ok thanks, I will look at that representation. I think you can close the ticket. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Ross Lawley [ 09/Jul/19 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
No problems - so either there is an issue with the AGGREGATE_IDENTIFIER or the UUID. I think its most likely going to be with the UUID - as there are differences in the way drivers have encoded them in the past. Do you know what representation the UUID was encoded in? Was it encoded / saved to MongoDB via the driver or via the shell or via some other driver? There is an example of how to change the UUID representation in the documentation in that example the representation is changed to UuidRepresentation.STANDARD. The best approach might be to issue a find query to determine the correct representation. You can use the BsonBinary helper to convert the UUID into a queryable BsonBinary value to quickly help determine the correct representation. (UUID's are stored as BsonBinary values inside MongoDB but different representations have different sub type flags). I hope that helps, Ross | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Debeissat Nicolas [ 05/Jul/19 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Ok, with the kind of filter you provide, it works thank you. Sorry for the noise, it seems the legacy code that created the filter (Bson filter= new BasicDBObject(AGGREGATE_IDENTIFIER, uuid)) did not work. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Ross Lawley [ 05/Jul/19 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks for the ticket - the limit set in the operation will not impact the deleteMany. As you can see from the delete command documentation:
Below is a quick test showing it working as expected:
When you run that code you can see that it deletes all the documents where i == 0. Obviously, if the filter doesn't match any documents then nothing will be deleted. I did notice the filter shown looks like a string representation of UUID - if the aggregateIdentifier was stored as a binary value then the filter wouldn't match any documents. I hope that helps / provides some insights, Ross |