Normalize QuerySets in subqueries.
Review Request #14756 — Created Dec. 31, 2025 and submitted — Latest diff uploaded
When a subquery includes a
QuerySet, it's impossible to match, because
even though the surroundingQobject attempts to check equality,
QuerySetequality is strictly based on identity.This change adds a check to see if the value in the Q object is a
QuerySet, and replace it with a subquery placeholder. This changes the
processedWHEREclause fromQ(group__in=<QuerySet []>)to
Q(group__in=('__QuerySet__subquery__', 1)), which can be included in
the expected result.
- Ran unit tests.
- Used in Review Board tests that (under Django 5.2) are including a
QuerySetin theWHEREclause.