Skip to content

Commit a65a92e

Browse files
committed
Fix columns got dirty after copy and modify inner values.
1 parent f6d360b commit a65a92e

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
@@ -121,12 +121,11 @@ def join(self, compiler, connection):
121121
columns.append((expr.rhs, None))
122122
replacements = {}
123123
for col, parent_pos in columns:
124-
column_target = col.copy()
125-
if column_target.alias == self.table_name:
126-
column_target.alias = compiler.collection_name
127-
else:
128-
column_target.target.db_column = f"{parent_template}{parent_pos}"
129-
column_target.target.set_attributes_from_name(f"{parent_template}{len(lhs_fields)}")
124+
# Make all columns in as main collection columns.
125+
column_target = Col(compiler.collection_name, expr.output_field.__class__())
126+
if column_target.alias != self.table_name:
127+
column_target.target.db_column = f"${parent_template}{parent_pos}"
128+
column_target.target.set_attributes_from_name(f"${parent_template}{parent_pos}")
130129
replacements[col] = column_target
131130
extra_condition = [extra.replace_expressions(replacements).as_mql(compiler, connection)]
132131
else:

0 commit comments

Comments
 (0)