#29172 closed Bug (fixed)
Using Window in Subquery causes AttributeError
Reported by: | Tomáš Ehrlich | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 2.0 |
Severity: | Normal | Keywords: | subquery window expression orm |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Using Window expression within Subquery causes an AttributeError: 'NoneType' object has no attribute ‘relabeled_clone'
Error is raised in relabeled_clone
method,
https://github.com/django/django/blob/master/django/db/models/expressions.py#L319
which calls e.relabeled_clone
method on every expression returned from get_source_expressions
.
Window expression returns source_expression
, partition_by
, order_by
and frame
in get_source_expression
:
https://github.com/django/django/blob/master/django/db/models/expressions.py#L1188
but all parameters except source_expression
are optional and might be None
. This leads to AttributeError.
Change History (5)
comment:1 by , 7 years ago
Has patch: | set |
---|
comment:2 by , 7 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 7 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
This seems reasonable yes. Test case from PR should work: