Make assertQSEqual error out if no ordering defined
|Reported by:||akaariai||Owned by:||nobody|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
An unordered queryset isn't guaranteed to return the values in any order. So, using assertQuerysetEqual comparing more than one value and an unordered qs with the ordered flag set is likely a programming error.
As seen from the linked patch this error is fairly common.
In practice databases usually return the values in insert order, so the error does not surface often. Still, this can be a source of heisenbugs as background database maintenance jobs can alter the ordering of the results.
The linked patch contains two commits, one for making assertQuerysetEqual fail if the ordering isn't well defined, and one to fix all the tests in Django where the ordering isn't well defined.
I guess we need a short mention in release notes about this?
Change History (6)
comment:1 Changed 4 years ago by claudep
- Needs documentation unset
- Needs tests set
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted
- Type changed from Uncategorized to Cleanup/optimization
- Version changed from 1.4 to master