Normalize QuerySets in subqueries.

Review Request #14756 — Created Dec. 31, 2025 and submitted — Latest diff uploaded

Information

django-assert-queries
main

Reviewers

When a subquery includes a QuerySet, it's impossible to match, because
even though the surrounding Q object attempts to check equality,
QuerySet equality 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
processed WHERE clause from Q(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
    QuerySet in the WHERE clause.

Commits

Files