diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-08-28 07:56:04 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-08-28 19:12:02 +0200 |
| commit | 655e1ce6b1ca8df71518060ae770c3ee647b9801 (patch) | |
| tree | 7393d043bf0f7a0aaeea8c8d7f10f8e5d36ae7e2 /tests/model_fields | |
| parent | 3a42c0447b6a3187bd2aaae0bba566d835c47d22 (diff) | |
[3.1.x] 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.
Backport of 0be51d2226fce030ac9ca840535a524f41e9832c from master
Diffstat (limited to 'tests/model_fields')
| -rw-r--r-- | tests/model_fields/test_jsonfield.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/model_fields/test_jsonfield.py b/tests/model_fields/test_jsonfield.py index debf02517a..a56b7e74df 100644 --- a/tests/model_fields/test_jsonfield.py +++ b/tests/model_fields/test_jsonfield.py @@ -336,6 +336,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( |
