mirror of
https://github.com/django/django.git
synced 2025-07-17 16:19:12 +00:00
[3.1.x] Refs #32203 -- Added tests for QuerySet.values()/values_list() on key transforms with non-trivial values.
Backport of 7408c4cd157ae18971302a2baf7aacce7c204a09 from master
This commit is contained in:
parent
97bfe0cba5
commit
a2abeb3de7
@ -680,6 +680,19 @@ class TestQuerying(TestCase):
|
|||||||
expected,
|
expected,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_key_values(self):
|
||||||
|
qs = NullableJSONModel.objects.filter(value__h=True)
|
||||||
|
tests = [
|
||||||
|
('value__a', 'b'),
|
||||||
|
('value__d', ['e', {'f': 'g'}]),
|
||||||
|
('value__j', None),
|
||||||
|
('value__k', {'l': 'm'}),
|
||||||
|
('value__n', [None]),
|
||||||
|
]
|
||||||
|
for lookup, expected in tests:
|
||||||
|
with self.subTest(lookup=lookup):
|
||||||
|
self.assertEqual(qs.values_list(lookup, flat=True).get(), expected)
|
||||||
|
|
||||||
@skipUnlessDBFeature('supports_json_field_contains')
|
@skipUnlessDBFeature('supports_json_field_contains')
|
||||||
def test_key_contains(self):
|
def test_key_contains(self):
|
||||||
self.assertIs(NullableJSONModel.objects.filter(value__foo__contains='ar').exists(), False)
|
self.assertIs(NullableJSONModel.objects.filter(value__foo__contains='ar').exists(), False)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user