Add support for extended subquery comparison in compare_queries().

Review Request #13402 — Created Nov. 6, 2023 and submitted — Latest diff uploaded

Information

Djblets
release-3.x

Reviewers

This reworks query comparison in compare_queries() and
assertQueries() to track and compare nested subqueries. Queries now
support a subqueries field, which follows the same format of the main
expected queries list, and this can be nested as deeply as required for
the queries being executed.

Any subquery inside of a where filter (via Subquery() or Exists())
will be transformed into a Q(__SubqueryType__subquery__=index) query,
since this allows for direct comparison and equates to an index within
the nested query comparison list.

The recent support for inner_query has been removed in favor of this
new support. Support is opt-in currently for assertQueries(), to
maintain backwards-compatibility, but will be enabled by default in
Djblets 5.

The normalization and formatting support has been enhanced to support
subqueries and F-expressions, and to display the way the code would be
written in Python with Q(...), F(...), etc. This makes it far easier
to compare and update queries.

Unit tests pass.

Tested this with in-progress code in Review Board.

Commits

Files

    Loading...