From d549b8805053d4b064bf492ba90e90db5d7e2a6b Mon Sep 17 00:00:00 2001 From: Mads Jensen Date: Mon, 18 Sep 2017 15:42:29 +0200 Subject: 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. --- django/db/models/sql/compiler.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'django/db/models/sql/compiler.py') 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( -- cgit v1.3