@@ -99,12 +99,12 @@ def join(self, compiler, connection):
99
99
# Add a join condition for each pair of joining fields.
100
100
for lhs , rhs in self .join_fields :
101
101
lhs , rhs = connection .ops .prepare_join_on_clause (
102
- self .parent_alias , lhs , self . table_name , rhs
102
+ self .parent_alias , lhs , compiler . collection_name , rhs
103
103
)
104
104
lhs_fields .append (lhs .as_mql (compiler , connection ))
105
105
# In the lookup stage, the reference to this column doesn't include
106
106
# the collection name.
107
- rhs_fields .append (rhs .as_mql (compiler , connection ). replace ( f" { self . table_name } ." , "" , 1 ) )
107
+ rhs_fields .append (rhs .as_mql (compiler , connection ))
108
108
109
109
parent_template = "parent__field__"
110
110
lookup_pipeline = [
@@ -115,7 +115,7 @@ def join(self, compiler, connection):
115
115
# The pipeline variables to be matched in the pipeline's
116
116
# expression.
117
117
"let" : {
118
- f"{ parent_template } { i } " : { "$toString" : parent_field }
118
+ f"{ parent_template } { i } " : parent_field
119
119
for i , parent_field in enumerate (lhs_fields )
120
120
},
121
121
"pipeline" : [
@@ -129,7 +129,7 @@ def join(self, compiler, connection):
129
129
"$match" : {
130
130
"$expr" : {
131
131
"$and" : [
132
- {"$eq" : [f"$${ parent_template } { i } " , { "$toString" : field } ]}
132
+ {"$eq" : [f"$${ parent_template } { i } " , field ]}
133
133
for i , field in enumerate (rhs_fields )
134
134
]
135
135
}
0 commit comments