1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #30027 -- Errored out on Window function usage if unsupported.

This commit is contained in:
Simon Charette
2019-01-15 21:48:12 -06:00
committed by Tim Graham
parent ebd2fe1861
commit 64d5bafbc6
2 changed files with 10 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
import datetime
from unittest import skipIf, skipUnless
from unittest import mock, skipIf, skipUnless
from django.core.exceptions import FieldError
from django.db import NotSupportedError, connection
@@ -821,6 +821,12 @@ class NonQueryWindowTests(SimpleTestCase):
with self.assertRaisesMessage(NotSupportedError, msg):
Employee.objects.annotate(dense_rank=Window(expression=DenseRank())).filter(dense_rank__gte=1)
def test_unsupported_backend(self):
msg = 'This backend does not support window expressions.'
with mock.patch.object(connection.features, 'supports_over_clause', False):
with self.assertRaisesMessage(NotSupportedError, msg):
Employee.objects.annotate(dense_rank=Window(expression=DenseRank())).get()
def test_invalid_order_by(self):
msg = 'order_by must be either an Expression or a sequence of expressions'
with self.assertRaisesMessage(ValueError, msg):