Add support for extended subquery comparison in compare_queries().
Review Request #13402 — Created Nov. 6, 2023 and submitted — Latest diff uploaded
This reworks query comparison in
compare_queries()
and
assertQueries()
to track and compare nested subqueries. Queries now
support asubqueries
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 (viaSubquery()
orExists()
)
will be transformed into aQ(__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 forassertQueries()
, 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 withQ(...)
,F(...)
, etc. This makes it far easier
to compare and update queries.
Unit tests pass.
Tested this with in-progress code in Review Board.