Details
-
Bug
-
Resolution: Duplicate
-
Major - P3
-
None
-
None
-
None
-
None
-
Query Execution
-
ALL
Description
Example:
db.agg_test.insertOne({"a": [31415, 9265]}); |
db.agg_test.aggregate([{$project: {"a.b": 1, "c": {$const: "test"}}}, {$addFields: {"a.d": "zzz"}}]); |
Result would be:
"a" : [ { "d" : "zzz" }, { "d" : "zzz" } ], "c" : "test" } |
Projection {"a.b": 1} will remove all scalar elements from the array "a" as per projection definition.
Additional $const expression is needed to use default projection implementation instead of a simplified one.
When projection iterates through array, it replaces deleted scalar values with "missing " values and then $addFields stage replaces "missing" values with objects.
Attachments
Issue Links
- duplicates
-
SERVER-50779 ProjectionExecutor incorrectly leaves tombstones when evaluating arrays
-
- Backlog
-