Fixed #34016 -- Fixed QuerySet.values()/values_list() crash on ArrayAgg() and JSONBAgg().
Regression in e06dc4571e
.
This commit is contained in:
parent
ae509f8f08
commit
f88fc72da4
|
@ -14,10 +14,13 @@ class OrderableAggMixin:
|
||||||
return super().resolve_expression(*args, **kwargs)
|
return super().resolve_expression(*args, **kwargs)
|
||||||
|
|
||||||
def get_source_expressions(self):
|
def get_source_expressions(self):
|
||||||
return super().get_source_expressions() + [self.order_by]
|
if self.order_by.source_expressions:
|
||||||
|
return super().get_source_expressions() + [self.order_by]
|
||||||
|
return super().get_source_expressions()
|
||||||
|
|
||||||
def set_source_expressions(self, exprs):
|
def set_source_expressions(self, exprs):
|
||||||
*exprs, self.order_by = exprs
|
if isinstance(exprs[-1], OrderByList):
|
||||||
|
*exprs, self.order_by = exprs
|
||||||
return super().set_source_expressions(exprs)
|
return super().set_source_expressions(exprs)
|
||||||
|
|
||||||
def as_sql(self, compiler, connection):
|
def as_sql(self, compiler, connection):
|
||||||
|
|
|
@ -18,3 +18,7 @@ Bugfixes
|
||||||
|
|
||||||
* Fixed a bug in Django 4.1 that caused an incorrect validation of
|
* Fixed a bug in Django 4.1 that caused an incorrect validation of
|
||||||
``CheckConstraint`` on ``NULL`` values (:ticket:`33996`).
|
``CheckConstraint`` on ``NULL`` values (:ticket:`33996`).
|
||||||
|
|
||||||
|
* Fixed a regression in Django 4.1 that caused a
|
||||||
|
``QuerySet.values()/values_list()`` crash on ``ArrayAgg()`` and
|
||||||
|
``JSONBAgg()`` (:ticket:`34016`).
|
||||||
|
|
|
@ -686,6 +686,15 @@ class TestGeneralAggregate(PostgreSQLTestCase):
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_values_list(self):
|
||||||
|
tests = [ArrayAgg("integer_field"), JSONBAgg("integer_field")]
|
||||||
|
for aggregation in tests:
|
||||||
|
with self.subTest(aggregation=aggregation):
|
||||||
|
self.assertCountEqual(
|
||||||
|
AggregateTestModel.objects.values_list(aggregation),
|
||||||
|
[([0],), ([1],), ([2],), ([0],)],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestAggregateDistinct(PostgreSQLTestCase):
|
class TestAggregateDistinct(PostgreSQLTestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
Loading…
Reference in New Issue