• 
      

    Add support for extended subquery comparison in compare_queries().

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

    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.

    Summary ID
    Add support for extended subquery comparison in compare_queries().
    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.
    57ba205b1bf983de9b02ec504d56d0edebe9c182
    Description From Last Updated

    'djblets.db.query_comparator.QueryMismatch' imported but unused Column: 5 Error code: F401

    reviewbot reviewbot

    Can get rid of this first paragraph since we say the same thing in the 2nd paragraph.

    maubin maubin

    There's an extra : here.

    maubin maubin
    Checks run (1 failed, 1 succeeded)
    flake8 failed.
    JSHint passed.

    flake8

    chipx86
    chipx86
    chipx86
    chipx86
    david
    1. Ship It!
    2. 
        
    maubin
    1. 
        
    2. djblets/db/query_comparator.py (Diff revision 5)
       
       
       
       
       
       
       
       
      Show all issues

      Can get rid of this first paragraph since we say the same thing in the 2nd paragraph.

    3. djblets/db/query_comparator.py (Diff revision 5)
       
       
      Show all issues

      There's an extra : here.

      1. While it looks like a mistake, it's actually ReST syntax for "the next indented thing is a code block". Short-hand for when .. code-block:: is too heavy-weight (and in fact is part of base ReST, rather than the Sphinx extension of directives).

      2. Oh got it.

    4. 
        
    chipx86
    maubin
    1. Ship It!
    2. 
        
    chipx86
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-3.x (d80aaa7)