• 
      

    Normalize the executed Q() in assertQueries to ease comparisons.

    Review Request #12357 — Created June 10, 2022 and submitted

    Information

    Djblets
    release-3.x

    Reviewers

    When calling MyModel.objects.filter(Q(...)), an extra wrapper Q()
    sometimes gets generated, resulting in an expression like
    Q(Q(field=value)). This is annoying to work with in tests, and feels
    wrong.

    To avoid this, we now post-process just a bit. If the Q() object
    contains only one child, and that child is another Q() object, we just
    extract the inner one.

    Tested with unit tests that were triggering this behavior.

    Summary ID
    Normalize the executed Q() in assertQueries to ease comparisons.
    When calling `MyModel.objects.filter(Q(...))`, an extra wrapper `Q()` sometimes gets generated, resulting in an expression like `Q(Q(field=value))`. This is annoying to work with in tests, and feels wrong. To avoid this, we now post-process just a bit. If the `Q()` object contains only one child, and that child is another `Q()` object, we just extract the inner one.
    548a41994127d8d4b28b3235e03d0693f2502ac9
    david
    1. Ship It!
    2. 
        
    chipx86
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-3.x (48e62ff)