mirror of
https://github.com/django/django.git
synced 2025-10-25 06:36:07 +00:00
Fixed #36085 -- Added JSONField support for negative array indexing on SQLite.
This commit is contained in:
@@ -785,6 +785,21 @@ class TestQuerying(TestCase):
|
||||
[self.objs[5]],
|
||||
)
|
||||
|
||||
@skipIfDBFeature("supports_json_negative_indexing")
|
||||
def test_unsupported_negative_lookup(self):
|
||||
msg = (
|
||||
"Using negative JSON array indices is not supported on this database "
|
||||
"backend."
|
||||
)
|
||||
with self.assertRaisesMessage(NotSupportedError, msg):
|
||||
NullableJSONModel.objects.filter(**{"value__-2": 1}).get()
|
||||
|
||||
@skipUnlessDBFeature("supports_json_negative_indexing")
|
||||
def test_shallow_list_negative_lookup(self):
|
||||
self.assertSequenceEqual(
|
||||
NullableJSONModel.objects.filter(**{"value__-2": 1}), [self.objs[5]]
|
||||
)
|
||||
|
||||
def test_shallow_obj_lookup(self):
|
||||
self.assertCountEqual(
|
||||
NullableJSONModel.objects.filter(value__a="b"),
|
||||
@@ -817,12 +832,26 @@ class TestQuerying(TestCase):
|
||||
[self.objs[5]],
|
||||
)
|
||||
|
||||
@skipUnlessDBFeature("supports_json_negative_indexing")
|
||||
def test_deep_negative_lookup_array(self):
|
||||
self.assertSequenceEqual(
|
||||
NullableJSONModel.objects.filter(**{"value__-1__0": 2}),
|
||||
[self.objs[5]],
|
||||
)
|
||||
|
||||
def test_deep_lookup_mixed(self):
|
||||
self.assertSequenceEqual(
|
||||
NullableJSONModel.objects.filter(value__d__1__f="g"),
|
||||
[self.objs[4]],
|
||||
)
|
||||
|
||||
@skipUnlessDBFeature("supports_json_negative_indexing")
|
||||
def test_deep_negative_lookup_mixed(self):
|
||||
self.assertSequenceEqual(
|
||||
NullableJSONModel.objects.filter(**{"value__d__-1__f": "g"}),
|
||||
[self.objs[4]],
|
||||
)
|
||||
|
||||
def test_deep_lookup_transform(self):
|
||||
self.assertCountEqual(
|
||||
NullableJSONModel.objects.filter(value__c__gt=2),
|
||||
|
||||
Reference in New Issue
Block a user