summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHannes Ljungberg <hannes.ljungberg@gmail.com>2020-11-09 17:54:20 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-11-10 08:13:03 +0100
commitcc3870c30f0338a09e440430d5dcc028d23f1a02 (patch)
treef0662ac2c50f1974f0147511e850cb38e526620a /tests
parentd67f965c799f15d45723027d2b42aec01a1d3ca2 (diff)
[3.1.x] Fixed #32182 -- Fixed crash of JSONField nested key transforms with subquery annotations on PostgreSQL.
Backport of 0773837e15bb632afffb6848a58c59a791008fa1 from master
Diffstat (limited to 'tests')
-rw-r--r--tests/model_fields/test_jsonfield.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/model_fields/test_jsonfield.py b/tests/model_fields/test_jsonfield.py
index ea9bc2775b..b91d94752f 100644
--- a/tests/model_fields/test_jsonfield.py
+++ b/tests/model_fields/test_jsonfield.py
@@ -385,6 +385,18 @@ class TestQuerying(TestCase):
[self.objs[4]],
)
+ def test_nested_key_transform_on_subquery(self):
+ self.assertSequenceEqual(
+ NullableJSONModel.objects.filter(value__d__0__isnull=False).annotate(
+ subquery_value=Subquery(
+ NullableJSONModel.objects.filter(pk=OuterRef('pk')).values('value')
+ ),
+ key=KeyTransform('d', 'subquery_value'),
+ chain=KeyTransform('f', KeyTransform('1', 'key')),
+ ).filter(chain='g'),
+ [self.objs[4]],
+ )
+
def test_expression_wrapper_key_transform(self):
self.assertSequenceEqual(
NullableJSONModel.objects.annotate(