Opened 3 years ago

Last modified 2 months ago

#28333 new New feature

Filter and subquery for window expressions

Reported by: Mads Jensen Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Normal Keywords: window orm filter subquery
Cc: Alexandr Artemyev, Andy Terra, Étienne Beaulé Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Mads Jensen)

#26608 will introduce window function expressions, but will disallow filtering on the result of them, e.g.:


is not allowed. Instead, the window function expression should be wrapped in an inner query, and the filtering should be done in an outer query.

Change History (5)

comment:1 Changed 3 years ago by Mads Jensen

Description: modified (diff)
Triage Stage: UnreviewedAccepted

comment:2 Changed 14 months ago by Bernd Wechner

This is 2 years old with no action and I am very keen to see it implemented (need it rather badly).

It strikes me as an aside that a more general approach may kill more birds with one stone. I noticed the rather excellent ExpressionWrapper(), and it struck me that a QueryWrapper() would be a more general solution that covers this particular need and will cover others as well, known and unknown at present.

In short QueryWrapper would simply make an inner query of the QuerySet to date so that subsequent operations act upon it as if it were a table.

Last edited 7 months ago by Bernd Wechner (previous) (diff)

comment:3 Changed 7 months ago by Alexandr Artemyev

Cc: Alexandr Artemyev added

comment:4 Changed 5 months ago by Andy Terra

Cc: Andy Terra added

comment:5 Changed 2 months ago by Étienne Beaulé

Cc: Étienne Beaulé added
Note: See TracTickets for help on using tickets.
Back to Top