Normalize the executed Q() in assertQueries to ease comparisons.
Review Request #12357 — Created June 10, 2022 and submitted
MyModel.objects.filter(Q(...)), an extra wrapper
sometimes gets generated, resulting in an expression like
Q(Q(field=value)). This is annoying to work with in tests, and feels
To avoid this, we now post-process just a bit. If the
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.