Skip to content

Commit 3959ca7

Browse files
committed
Fix wrong projection joined collection.
1 parent 60e7eb1 commit 3959ca7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

django_mongodb/datastructures.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,17 @@ def join(self, compiler, connection):
5151
if self.join_type != INNER:
5252
lookups_pipeline.append(
5353
{
54-
"$project": {
54+
"$set": {
5555
self.table_alias: {
5656
"$cond": {
5757
"if": {
5858
"$or": [
59-
{"$eq": [{"$type": "$arrayField"}, "missing"]},
60-
{"$eq": [{"$size": "$arrayField"}, 0]},
59+
{"$eq": [{"$type": f"${self.table_alias}"}, "missing"]},
60+
{"$eq": [{"$size": f"${self.table_alias}"}, 0]},
6161
]
6262
},
63-
"then": [None],
64-
"else": "$arrayField",
63+
"then": [{}],
64+
"else": f"${self.table_alias}",
6565
}
6666
}
6767
}

0 commit comments

Comments
 (0)