From f210de760b06cd57ff37b416e2bf9eafb0bfe929 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Mon, 29 Aug 2022 09:14:56 +0200 Subject: [PATCH] Refs #28333 -- Fixed NonQueryWindowTests.test_invalid_filter() on databases that don't support window expressions. --- tests/expressions_window/tests.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/expressions_window/tests.py b/tests/expressions_window/tests.py index a71a3f947d..f3413102d5 100644 --- a/tests/expressions_window/tests.py +++ b/tests/expressions_window/tests.py @@ -1557,6 +1557,20 @@ class WindowFunctionTests(TestCase): ) ) + def test_invalid_filter(self): + msg = ( + "Heterogeneous disjunctive predicates against window functions are not " + "implemented when performing conditional aggregation." + ) + qs = Employee.objects.annotate( + window=Window(Rank()), + past_dept_cnt=Count("past_departments"), + ) + with self.assertRaisesMessage(NotImplementedError, msg): + list(qs.filter(Q(window=1) | Q(department="Accounting"))) + with self.assertRaisesMessage(NotImplementedError, msg): + list(qs.exclude(window=1, department="Accounting")) + class WindowUnsupportedTests(TestCase): def test_unsupported_backend(self): @@ -1613,20 +1627,6 @@ class NonQueryWindowTests(SimpleTestCase): with self.assertRaisesMessage(NotImplementedError, msg): frame.window_frame_start_end(None, None, None) - def test_invalid_filter(self): - msg = ( - "Heterogeneous disjunctive predicates against window functions are not " - "implemented when performing conditional aggregation." - ) - qs = Employee.objects.annotate( - window=Window(Rank()), - past_dept_cnt=Count("past_departments"), - ) - with self.assertRaisesMessage(NotImplementedError, msg): - list(qs.filter(Q(window=1) | Q(department="Accounting"))) - with self.assertRaisesMessage(NotImplementedError, msg): - list(qs.exclude(window=1, department="Accounting")) - def test_invalid_order_by(self): msg = ( "Window.order_by must be either a string reference to a field, an "