Backport of 9c19aff7c7561e3a82978a272ecdaad40dda5c00 from main.
This also replaces assertQuerysetEqual() to assertSequenceEqual()/assertCountEqual() where appropriate. Co-authored-by: Peter Inglesby <peter.inglesby@gmail.com> Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
MySQL 5.5 (refs #28552) was the last database to use it.