diff options
| author | Mads Jensen <mje@inducks.org> | 2017-09-18 15:42:29 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-09-18 09:42:29 -0400 |
| commit | d549b8805053d4b064bf492ba90e90db5d7e2a6b (patch) | |
| tree | 2beee237ae541804ba18367d81e82840745d6e47 /django/db/models/sql/query.py | |
| parent | da1ba03f1dfb303df9bfb5c76d36216e45d05edc (diff) | |
Fixed #26608 -- Added support for window expressions (OVER clause).
Thanks Josh Smeaton, Mariusz Felisiak, Sergey Fedoseev, Simon Charettes,
Adam Chainz/Johnson and Tim Graham for comments and reviews and Jamie
Cockburn for initial patch.
Diffstat (limited to 'django/db/models/sql/query.py')
| -rw-r--r-- | django/db/models/sql/query.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 017edea873..4cd22c7b8a 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -13,7 +13,7 @@ from string import ascii_uppercase from django.core.exceptions import ( EmptyResultSet, FieldDoesNotExist, FieldError, ) -from django.db import DEFAULT_DB_ALIAS, connections +from django.db import DEFAULT_DB_ALIAS, NotSupportedError, connections from django.db.models.aggregates import Count from django.db.models.constants import LOOKUP_SEP from django.db.models.expressions import Col, Ref @@ -1125,6 +1125,13 @@ class Query: if not arg: raise FieldError("Cannot parse keyword query %r" % arg) lookups, parts, reffed_expression = self.solve_lookup_type(arg) + + if not getattr(reffed_expression, 'filterable', True): + raise NotSupportedError( + reffed_expression.__class__.__name__ + ' is disallowed in ' + 'the filter clause.' + ) + if not allow_joins and len(parts) > 1: raise FieldError("Joined field references are not permitted in this query") |
