$merge results in duplicates
Solved
The $merge operator is creating duplicates that do not happen when the same query is executed via MongoDB console. I have a simple collection called “details”:
{ "_id" : ObjectId("5e18c9a02a24ce9706adc71b"), "x" : 5, "name" : "kate4" }, { "_id" : ObjectId("5e18c9a02a24ce9706adc71a"), "x" : 4, "name" : "kate3" }, { "_id" : ObjectId("5e18c9a02a24ce9706adc719"), "x" : 3, "name" : "kate2" }, { "_id" : ObjectId("5e18c9a02a24ce9706adc718"), "x" : 2, "name" : "kate1" }, { "_id" : ObjectId("5e18c9a02a24ce9706adc717"), "x" : 1, "name" : "smith" }
I then run this query:
db.details.aggregate([ {"$group":{ _id:{}, "sum":{$sum:"$x"} } }, {"$project":{"_id":0,"sum":1}} {"$merge": {"into": "summary"} }
])
BUT, every time it runs it creates two docs in the summary table. When I run the same query through MongoDB console, it creates one document as expected. Please investigate.
Thank you for your bug report. We have worked out a new test build to resolve this issue, please download and give it a try.
Mac OS: https://s3.mongobooster.com/download/releasesv5/nosqlbooster4mongo-5.2.9-beta.1.dmg
Thank you for your bug report. We have worked out a new test build to resolve this issue, please download and give it a try.
Mac OS: https://s3.mongobooster.com/download/releasesv5/nosqlbooster4mongo-5.2.9-beta.1.dmg
I installed the new build and re-tested. Looks like the fix works! Thank you.
I installed the new build and re-tested. Looks like the fix works! Thank you.
Replies have been locked on this page!