summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2020-08-28 07:56:04 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-08-28 19:09:46 +0200
commit0be51d2226fce030ac9ca840535a524f41e9832c (patch)
treef169982fe9af369944ac3130c9a50c675929dc1f /tests
parent22105391424cc56f29f153bb76d6a15246152674 (diff)
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/backends/base/test_operations.py5
-rw-r--r--tests/model_fields/test_jsonfield.py12
2 files changed, 12 insertions, 5 deletions
diff --git a/tests/backends/base/test_operations.py b/tests/backends/base/test_operations.py
index 5c622e157e..1cfea44e83 100644
--- a/tests/backends/base/test_operations.py
+++ b/tests/backends/base/test_operations.py
@@ -117,11 +117,6 @@ class SimpleDatabaseOperationTests(SimpleTestCase):
with self.assertRaisesMessage(NotImplementedError, self.may_require_msg % 'datetime_extract_sql'):
self.ops.datetime_extract_sql(None, None, None)
- def test_json_cast_text_sql(self):
- msg = self.may_require_msg % 'json_cast_text_sql'
- with self.assertRaisesMessage(NotImplementedError, msg):
- self.ops.json_cast_text_sql(None)
-
class DatabaseOperationTests(TestCase):
def setUp(self):
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(