Opened 7 years ago
Closed 7 years ago
#30104 closed Uncategorized (invalid)
Need filtering by Window expression
| Reported by: | Farid | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 2.1 |
| Severity: | Normal | Keywords: | orm, window, row_number, filter |
| Cc: | Farid | Triage Stage: | Unreviewed |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | yes | UI/UX: | no |
Description
I use Row_Number function with WIndow expression. And i need to filter only second rows.
History.objects.annotate(row=Window(expression=RowNumber(), partition_by=[F('ad_id')], order_by=F('updated_at').desc())).filter(row=2)
But this exception raised:
django.db.utils.NotSupportedError: Window is disallowed in the filter clause.
Why Window is disallowed in the filter clause? Is there other way to do this?
Change History (2)
comment:1 by , 7 years ago
| Cc: | added |
|---|
comment:2 by , 7 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
See the docs for `Window.filterable`: