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:12:02 +0200
commit655e1ce6b1ca8df71518060ae770c3ee647b9801 (patch)
tree7393d043bf0f7a0aaeea8c8d7f10f8e5d36ae7e2 /tests
parent3a42c0447b6a3187bd2aaae0bba566d835c47d22 (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')
-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 0ef2be73b0..17ee616f94 100644
--- a/tests/backends/base/test_operations.py
+++ b/tests/backends/base/test_operations.py
@@ -121,11 +121,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 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(