-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Execution
-
ALL
In the classic engine, $lookup (specified with localField/foreignField syntax) fails when a local field is undefined:
> db.foo.find() { "_id" : ObjectId("672b7fa1046b20cdaa4eba47"), "a" : undefined } > db.foo.aggregate([{$lookup: {from: "foo", localField: "a", foreignField: "a", as: "res"}}]) uncaught exception: Error: command failed: { "ok" : 0, "errmsg" : "PlanExecutor error during aggregation :: caused by :: cannot compare to undefined", "code" : 2, "codeName" : "BadValue" }
But with SBE enabled, this query succeeds:
> db.foo.find() { "_id" : ObjectId("672b7fa1046b20cdaa4eba47"), "a" : undefined } > db.foo.aggregate([{$lookup: {from: "foo", localField: "a", foreignField: "a", as: "res"}}]) { "_id" : ObjectId("672b7fa1046b20cdaa4eba47"), "a" : undefined, "res" : [ { "_id" : ObjectId("672b7fa1046b20cdaa4eba47"), "a" : undefined } ] }
- duplicates
-
SERVER-64587 Fail $lookup when undefined is a value from the local side
- Closed