-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Critical - P2
-
None
-
Affects Version/s: 8.0.13
-
Component/s: None
-
None
-
Query Execution
-
ALL
-
-
None
-
None
-
None
-
None
-
None
-
None
-
None
> db.foo.drop() db.aggregate([{$documents:[{z: 1, a: 1}]}, {$merge: {into: "foo", whenMatched:"keepExisting", whenNotMatched:"insert"}}]) db.foo.find()
When I run the above I get:
[ { _id: ObjectId('68baf740fcc543022431a453'), a: 1, z: 1 } ]
Note that `find` shows the `a` field first, even though the aggregation has `z` first.
Per max.hirschhorn@mongodb.com, this bug is specific to this pair of whenMatched/whenNotMatched settings. It does not happen, for example, if `whenMatched` is `replace`.
Workaround
whenMatched: [{$replaceWith: "$$ROOT"}]
- is related to
-
SERVER-63853 $merge breaks fields order. It is critical for bioinformatics
-
- Closed
-
- related to
-
SERVER-74408 Insert document exactly as specified on upserts
-
- Closed
-