Avoid cloning Q objects in assertQueries().
Review Request #12368 — Created June 13, 2022 and submitted — Latest diff uploaded
As a precaution,
assertQueries()attempted to clone
deepcopy. This ended up being a bad idea, for two reasons.
Q()handles its own cloning logic already, and is careful about
it. Mostly because of the second reason.
deepcopyends up cloning the model instances and their
fields and other state, which has side effects and is incompatible
with some types of data (such as the
RelationCounterField, due to
We now just use the instances as normal, leaving it up to
the right thing.
All unit tests using
assertQueries()pass, and in-progress ones that
hit these issues no longer cause Python to crash.