Skip to content

Commit 129893f

Browse files
committed
Fix unintended overwrite of column.target.
1 parent a9d1156 commit 129893f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

django_mongodb_backend/query.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def extra_where(self, compiler, connection): # noqa: ARG001
132132
def join(self, compiler, connection, pushed_expressions=None):
133133
def _get_reroot_replacements(expressions):
134134
if not expressions:
135-
return []
135+
return None
136136
columns = []
137137
for expr in expressions:
138138
# Determine whether the column needs to be transformed or rerouted
@@ -152,7 +152,9 @@ def _get_reroot_replacements(expressions):
152152
# based on their rerouted positions in the join pipeline.
153153
replacements = {}
154154
for col, parent_pos in columns:
155-
column_target = Col(compiler.collection_name, col.target, col.output_field)
155+
target = col.target.clone()
156+
target.remote_field = col.target.remote_field
157+
column_target = Col(compiler.collection_name, target)
156158
if parent_pos is not None:
157159
target_col = f"${parent_template}{parent_pos}"
158160
column_target.target.db_column = target_col

0 commit comments

Comments
 (0)