@@ -99,12 +99,12 @@ def join(self, compiler, connection):
9999 # Add a join condition for each pair of joining fields.
100100 for lhs , rhs in self .join_fields :
101101 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
103103 )
104104 lhs_fields .append (lhs .as_mql (compiler , connection ))
105105 # In the lookup stage, the reference to this column doesn't include
106106 # 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 ))
108108
109109 parent_template = "parent__field__"
110110 lookup_pipeline = [
@@ -115,7 +115,7 @@ def join(self, compiler, connection):
115115 # The pipeline variables to be matched in the pipeline's
116116 # expression.
117117 "let" : {
118- f"{ parent_template } { i } " : { "$toString" : parent_field }
118+ f"{ parent_template } { i } " : parent_field
119119 for i , parent_field in enumerate (lhs_fields )
120120 },
121121 "pipeline" : [
@@ -129,7 +129,7 @@ def join(self, compiler, connection):
129129 "$match" : {
130130 "$expr" : {
131131 "$and" : [
132- {"$eq" : [f"$${ parent_template } { i } " , { "$toString" : field } ]}
132+ {"$eq" : [f"$${ parent_template } { i } " , field ]}
133133 for i , field in enumerate (rhs_fields )
134134 ]
135135 }
0 commit comments