summaryrefslogtreecommitdiff
path: root/django/db/models/sql/query.py
diff options
context:
space:
mode:
authorPeter DeVita <mewtwo2643@yahoo.com>2025-01-17 13:22:24 -0500
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-01-27 10:34:16 +0100
commit720ef7a867eab1491f5789fe39b3431a498b2b89 (patch)
tree851849e386b06392dad3ef58fcef148ba7cf0b1c /django/db/models/sql/query.py
parentb285cc787ecfd6d8305ee9c8cb84edbf95e59f36 (diff)
[5.2.x] Fixed #36109 -- Fixed RecursionError when stacking FilteredRelation joins.
Backport of 8eca4077f60fa0705ecfd9437c9ceaeef7a3808b from main.
Diffstat (limited to 'django/db/models/sql/query.py')
-rw-r--r--django/db/models/sql/query.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index 6fbf854e67..ddf6c891fa 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -1946,6 +1946,8 @@ class Query(BaseExpression):
reuse = can_reuse if join.m2m else None
alias = self.join(connection, reuse=reuse)
joins.append(alias)
+ if join.filtered_relation and can_reuse is not None:
+ can_reuse.add(alias)
return JoinInfo(final_field, targets, opts, joins, path, final_transformer)
def trim_joins(self, targets, joins, path):