Fixed #30332 -- Fixed crash of ordering by expressions with params in ArrayAgg and StringAgg.

This commit is contained in:
Simone Pellizzari 2019-04-06 13:45:22 +02:00 committed by Mariusz Felisiak
parent 47a1f2a06f
commit d0315584b5
No known key found for this signature in database
GPG key ID: 2EF56372BA48CD1B
3 changed files with 24 additions and 6 deletions

View file

@ -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):