#31060: Window expression are not allowed in
-------------------------------------+-------------------------------------
Reporter: felixxm | Owner: nobody
Type: Bug | Status: new
Component: Database | Version: 3.0
layer (models, ORM) |
Severity: Release | Keywords:
blocker |
Triage Stage: Accepted | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Django raises `NotSupportedError` when using window expressions in
conditional statements used only in the `SELECT` clause, e.g.
{{{
Employee.objects.annotate(
lag=Window(
expression=Lag(expression='salary', offset=1),
partition_by=F('department'),
order_by=[F('salary').asc(), F('name').asc()],
),
is_changed=Case(
When(salary=F('lag'), then=Value(False)),
default=Value(True), output_field=BooleanField()
),
)
}}}
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.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/050.be237db19e5b6e6435387a6336304f47%40djangoproject.com.