Changes between Initial Version and Version 1 of Ticket #24218
- Timestamp:
- Jan 25, 2015, 3:23:26 PM (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #24218 – Description
initial v1 36 36 The above is perfectly valid SQL and produces expected results (please note that {{{ORDER_BY}}} is in the outer query to guarantee that distinct results are correctly sorted). 37 37 38 I created a simple [https://gist.github.com/miki725/ce26d8b6ee2f3075884a patch] by overwriting few things in {{{SQLCompiler.as_sql()}}} which seems to work pretty well. The patch only creates subquery when the above dilema is encountered which should not have any negative side-effects on existing queries (since such queries were not allowed by SQL). The patch also works on the {{{.count()}}} queries since Django then strips any ordering hence the subquery is never created.38 I created a simple proof-of-concept [https://gist.github.com/miki725/ce26d8b6ee2f3075884a patch] by overwriting few things in {{{SQLCompiler.as_sql()}}} which seems to work pretty well. The patch only creates subquery when the above dilema is encountered which should not have any negative side-effects on existing queries (since such queries were not allowed by SQL). The patch also works on the {{{.count()}}} queries since Django then strips any ordering hence the subquery is never created.