Skip to content

Commit a556c35

Browse files
committed
Fix from table in subqueries.
1 parent cd76b44 commit a556c35

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

django_mongodb/expressions.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,12 @@ def query(self, compiler, connection):
101101
else None
102102
)
103103
table_output = f"__subquery{len(compiler.subqueries)}"
104+
from_table = next(
105+
e.table_name for alias, e in self.alias_map.items() if self.alias_refcount[alias]
106+
)
104107
subquery.lookup_data = {
105108
"as": table_output,
106-
"from": self.get_meta().db_table,
109+
"from": from_table,
107110
"let": {
108111
compiler.PARENT_FIELD_TEMPLATE.format(i): col.as_mql(compiler, connection)
109112
for col, i in subquery_compiler.column_mapping.items()

0 commit comments

Comments
 (0)