SBE re-orders the fields in bson with the project stage {$project: {"obj.obj.obj.obj.array": 0}}.
In SBE's implementation, the object {obj: xx, any:xx } is first copied without specific field excluded from projections (obj in this case), then append the field back if only part of the object is excluded (only obj.array is excluded in this case). With this algorithm, the fields order is changed after projection stage.
When there is a $lookup stage with self-lookup after the project stage, the re-ordered object can't be matched to the original object, and output incorrect result.
- is depended on by
-
SERVER-76510 Make makeBsonObj() preserve field order
-
- Closed
-