From 0be51d2226fce030ac9ca840535a524f41e9832c Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Fri, 28 Aug 2020 07:56:04 +0200 Subject: Fixed #31956 -- Fixed crash of ordering by JSONField with a custom decoder on PostgreSQL. Thanks Marc Debureaux for the report. Thanks Simon Charette, Nick Pope, and Adam Johnson for reviews. --- tests/model_fields/test_jsonfield.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/model_fields') diff --git a/tests/model_fields/test_jsonfield.py b/tests/model_fields/test_jsonfield.py index 320d518554..665e46e6a3 100644 --- a/tests/model_fields/test_jsonfield.py +++ b/tests/model_fields/test_jsonfield.py @@ -359,6 +359,18 @@ class TestQuerying(TestCase): ).values('value__d__0').annotate(count=Count('value__d__0')).order_by('count') self.assertQuerysetEqual(qs, [1, 11], operator.itemgetter('count')) + def test_order_grouping_custom_decoder(self): + NullableJSONModel.objects.create(value_custom={'a': 'b'}) + qs = NullableJSONModel.objects.filter(value_custom__isnull=False) + self.assertSequenceEqual( + qs.values( + 'value_custom__a', + ).annotate( + count=Count('id'), + ).order_by('value_custom__a'), + [{'value_custom__a': 'b', 'count': 1}], + ) + def test_key_transform_raw_expression(self): expr = RawSQL(self.raw_sql, ['{"x": "bar"}']) self.assertSequenceEqual( -- cgit v1.3