summaryrefslogtreecommitdiff
path: root/tests/postgres_tests/test_aggregates.py
diff options
context:
space:
mode:
authorSimone Pellizzari <simone6021@libero.it>2019-04-06 13:45:22 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-04-06 14:23:29 +0200
commitd0315584b5ed6a47b486e65f6c88f80189f337ef (patch)
treeef3f0a7dea15c43c2d1bdd8aad29054f1b61c4f5 /tests/postgres_tests/test_aggregates.py
parent47a1f2a06fac2ee88d3ba9d88e8f7c45a4f6f5e8 (diff)
downloaddjango-d0315584b5ed6a47b486e65f6c88f80189f337ef.tar.gz
Fixed #30332 -- Fixed crash of ordering by expressions with params in ArrayAgg and StringAgg.
Diffstat (limited to 'tests/postgres_tests/test_aggregates.py')
-rw-r--r--tests/postgres_tests/test_aggregates.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/postgres_tests/test_aggregates.py b/tests/postgres_tests/test_aggregates.py
index 6b77787dcc..23f3c59ded 100644
--- a/tests/postgres_tests/test_aggregates.py
+++ b/tests/postgres_tests/test_aggregates.py
@@ -1,6 +1,7 @@
import json
from django.db.models.expressions import F, Value
+from django.db.models.functions import Concat, Substr
from django.test.utils import Approximate
from . import PostgreSQLTestCase
@@ -37,6 +38,12 @@ class TestGeneralAggregate(PostgreSQLTestCase):
((F('boolean_field'), F('char_field').desc()), ['Foo4', 'Foo2', 'Foo3', 'Foo1']),
('char_field', ['Foo1', 'Foo2', 'Foo3', 'Foo4']),
('-char_field', ['Foo4', 'Foo3', 'Foo2', 'Foo1']),
+ (Concat('char_field', Value('@')), ['Foo1', 'Foo2', 'Foo3', 'Foo4']),
+ (Concat('char_field', Value('@')).desc(), ['Foo4', 'Foo3', 'Foo2', 'Foo1']),
+ (
+ (Substr('char_field', 1, 1), F('integer_field'), Substr('char_field', 4, 1).desc()),
+ ['Foo3', 'Foo1', 'Foo2', 'Foo4'],
+ ),
)
for ordering, expected_output in ordering_test_cases:
with self.subTest(ordering=ordering, expected_output=expected_output):
@@ -166,6 +173,8 @@ class TestGeneralAggregate(PostgreSQLTestCase):
(F('char_field'), 'Foo1;Foo2;Foo3;Foo4'),
('char_field', 'Foo1;Foo2;Foo3;Foo4'),
('-char_field', 'Foo4;Foo3;Foo2;Foo1'),
+ (Concat('char_field', Value('@')), 'Foo1;Foo2;Foo3;Foo4'),
+ (Concat('char_field', Value('@')).desc(), 'Foo4;Foo3;Foo2;Foo1'),
)
for ordering, expected_output in ordering_test_cases:
with self.subTest(ordering=ordering, expected_output=expected_output):