Skip to content

Commit fc00a80

Browse files
committed
Fix columns got dirty after copy and modify inner values.
1 parent 339cae9 commit fc00a80

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

django_mongodb/query.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,11 @@ def join(self, compiler, connection):
117117
columns.append((expr.rhs, None))
118118
replacements = {}
119119
for col, parent_pos in columns:
120-
column_target = col.copy()
121-
if column_target.alias == self.table_name:
122-
column_target.alias = compiler.collection_name
123-
else:
124-
column_target.target.db_column = f"{parent_template}{parent_pos}"
125-
column_target.target.set_attributes_from_name(f"{parent_template}{len(lhs_fields)}")
120+
# Make all columns in as main collection columns.
121+
column_target = Col(compiler.collection_name, expr.output_field.__class__())
122+
if column_target.alias != self.table_name:
123+
column_target.target.db_column = f"${parent_template}{parent_pos}"
124+
column_target.target.set_attributes_from_name(f"${parent_template}{parent_pos}")
126125
replacements[col] = column_target
127126
extra_condition = [extra.replace_expressions(replacements).as_mql(compiler, connection)]
128127
else:

0 commit comments

Comments
 (0)