20600 - Subqueries should retain ORDER BY when using DISTINCT ON

I tried pinpointing where the bug is occurring but was not successful. Towards the end I started to suspect that the problem is in how the SQL query is executed and thus the problem to be in `sql_with_params()`.

The bug ticket: https://code.djangoproject.com/ticket/20600