Changes between Initial Version and Version 1 of Ticket #33768
- Timestamp:
- Jun 5, 2022, 2:47:04 PM (3 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #33768 – Description
initial v1 47 47 }}} 48 48 49 Due to the `UNION` we are rewriting queries to use column numbers so we can somewhat reliably target the columns. This breaks down when `nulls_first/last` is used because `(1) IS NULL` is interpreted as expression in mysql and not as the colname 1 being NULL. Which brings me back to https://twitter.com/fapolloner/status/1533512493208936450 -- I think that the rewriting of this eexpression should happen in the compiler and not in `OrderBy` itself. This way we could duplicate the `OrderBy` into two and push them into the relevant select clauses like we already do in https://github.com/django/django/blob/49b470b9187b6be60e573fed08c8f4a87f133750/django/db/models/sql/compiler.py#L410 for other things.49 Due to the `UNION` we are rewriting queries to use column numbers so we can somewhat reliably target the columns. This breaks down when `nulls_first/last` is used because `(1) IS NULL` is interpreted as expression in mysql and not as the colname 1 being NULL. Which brings me back to https://twitter.com/fapolloner/status/1533512493208936450 -- I think that the rewriting of this expression should happen in the compiler and not in `OrderBy` itself. This way we could duplicate the `OrderBy` into two and push them into the relevant select clauses like we already do in https://github.com/django/django/blob/49b470b9187b6be60e573fed08c8f4a87f133750/django/db/models/sql/compiler.py#L410 for other things. 50 50 51 51 Sadly it is a mess… Thoughts? Paging Adam since he was the resident MySQL specialist IIRC :)