summaryrefslogtreecommitdiff
path: root/django/db/models/sql/compiler.py
diff options
context:
space:
mode:
authorMads Jensen <mje@inducks.org>2017-09-18 15:42:29 +0200
committerTim Graham <timograham@gmail.com>2017-09-18 09:42:29 -0400
commitd549b8805053d4b064bf492ba90e90db5d7e2a6b (patch)
tree2beee237ae541804ba18367d81e82840745d6e47 /django/db/models/sql/compiler.py
parentda1ba03f1dfb303df9bfb5c76d36216e45d05edc (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/compiler.py')
-rw-r--r--django/db/models/sql/compiler.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
index 01c303eb7e..11ff51f60f 100644
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -1107,6 +1107,8 @@ class SQLInsertCompiler(SQLCompiler):
)
if value.contains_aggregate:
raise FieldError("Aggregate functions are not allowed in this query")
+ if value.contains_over_clause:
+ raise FieldError('Window expressions are not allowed in this query.')
else:
value = field.get_db_prep_save(value, connection=self.connection)
return value
@@ -1262,6 +1264,8 @@ class SQLUpdateCompiler(SQLCompiler):
val = val.resolve_expression(self.query, allow_joins=False, for_save=True)
if val.contains_aggregate:
raise FieldError("Aggregate functions are not allowed in this query")
+ if val.contains_over_clause:
+ raise FieldError('Window expressions are not allowed in this query.')
elif hasattr(val, 'prepare_database_save'):
if field.remote_field:
val = field.get_db_prep_save(