Add support for extended subquery comparison in compare_queries().
Review Request #13402 — Created Nov. 6, 2023 and submitted
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.
Summary | ID |
---|---|
57ba205b1bf983de9b02ec504d56d0edebe9c182 |
- Change Summary:
-
Removed an unused import.
- Commits:
-
Summary ID 07f6cf2d1320aaa969ac52c2d554495c0b3f9ce2 651308090d58b1ff905af35eb509f664c57fa98e
Checks run (2 succeeded)
- Change Summary:
-
Added some missing modifications to
assertQueries()
for somecompare_queries()
changes. - Commits:
-
Summary ID 651308090d58b1ff905af35eb509f664c57fa98e 4f4b49507766eab0f1ebc87a15208bf6cfcd7abd
Checks run (2 succeeded)
- Change Summary:
-
Fixed reporting mismatched subqueries when the parent query's attributes matched.
- Commits:
-
Summary ID 4f4b49507766eab0f1ebc87a15208bf6cfcd7abd f5ad3222935a7320725a6fbc1d5c22f7c5077c83
Checks run (2 succeeded)
- Change Summary:
-
- Fixed some regressions in the legacy no-subqueries mode.
- Expected queries no longer have their subqueries normalized, in order to force expected queries to provide the new subquery placeholders.
- Commits:
-
Summary ID f5ad3222935a7320725a6fbc1d5c22f7c5077c83 f6b4db082790484f98176f5d305d279e118afb6d