The SQL standard disallows referencing window functions in the `WHERE`
clause but in this case it's only used in the `SELECT` clause so this
should be possible.
Thanks utapyngo for the report.
Regression in 4edad1ddf6203326e0be4bdb105beecb0fe454c4.
--
Ticket URL: <https://code.djangoproject.com/ticket/31060>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
Ticket URL: <https://code.djangoproject.com/ticket/31060#comment:1>
* cc: Alexandr Artemyev (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/31060#comment:2>
Comment (by Alex Aktsipetrov):
So it seems a bugfix would envolve moving the raise from `build_filter` to
`add_q`.
And we would have to propagate the necessity of the raise somehow, in
WhereNode or as an additional return param.
--
Ticket URL: <https://code.djangoproject.com/ticket/31060#comment:3>
* owner: nobody => Alex Aktsipetrov
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/31060#comment:4>
Comment (by Simon Charette):
Given `build_filter` now calls `_add_q` on the master branch the solution
will probably involve adding a new kwarg to disable the `check_filterable`
check instead instead.
--
Ticket URL: <https://code.djangoproject.com/ticket/31060#comment:5>
Comment (by Alex Aktsipetrov):
Yeah, that works too (and is easier to implement).
Btw the comment in _add_q `Add a Q-object to the current filter` seems to
be misleading, considering the usage in CASE-WHEN...
--
Ticket URL: <https://code.djangoproject.com/ticket/31060#comment:6>
Comment (by Simon Charette):
Agreed that the comment is misleading, it has been for a while though. The
whole interactions between `_add_q`, `add_q`, and `build_filter` could
probably be better expressed as `add_q`, `_build_q`, and `build_filter` as
only `add_q` actually append nodes to the current query. The other methods
only make sure `query.aliases` contains `Join` references to table
necessary for the filter conditions.
--
Ticket URL: <https://code.djangoproject.com/ticket/31060#comment:7>
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/12185 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/31060#comment:8>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"bf12273db4e53779546e2ac7b65c0ce8e3c8a640" bf12273d]:
{{{
#!CommitTicketReference repository=""
revision="bf12273db4e53779546e2ac7b65c0ce8e3c8a640"
Fixed #31060 -- Reallowed window expressions to be used in conditions
outside of queryset filters.
Regression in 4edad1ddf6203326e0be4bdb105beecb0fe454c4.
Thanks utapyngo for the report.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31060#comment:9>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"8af07712df54efbd1d3d9130ab90236f530278c1" 8af07712]:
{{{
#!CommitTicketReference repository=""
revision="8af07712df54efbd1d3d9130ab90236f530278c1"
[3.0.x] Fixed #31060 -- Reallowed window expressions to be used in
conditions outside of queryset filters.
Regression in 4edad1ddf6203326e0be4bdb105beecb0fe454c4.
Thanks utapyngo for the report.
Backport of bf12273db4e53779546e2ac7b65c0ce8e3c8a640 from master.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31060#comment:10>