Changes between Initial Version and Version 1 of Ticket #24218


Ignore:
Timestamp:
01/25/2015 03:23:26 PM (5 years ago)
Author:
Miroslav Shubernetskiy
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #24218 – Description

    initial v1  
    3636The 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).
    3737
    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.
     38I 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.
Back to Top