mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #25666 -- Fixed the exact lookup of ArrayField.
This commit is contained in:
parent
b8f78823ee
commit
263b3d2ba1
3 changed files with 95 additions and 3 deletions
|
@ -122,6 +122,20 @@ class TestQuerying(PostgreSQLTestCase):
|
|||
self.objs[:1]
|
||||
)
|
||||
|
||||
def test_exact_charfield(self):
|
||||
instance = CharArrayModel.objects.create(field=['text'])
|
||||
self.assertSequenceEqual(
|
||||
CharArrayModel.objects.filter(field=['text']),
|
||||
[instance]
|
||||
)
|
||||
|
||||
def test_exact_nested(self):
|
||||
instance = NestedIntegerArrayModel.objects.create(field=[[1, 2], [3, 4]])
|
||||
self.assertSequenceEqual(
|
||||
NestedIntegerArrayModel.objects.filter(field=[[1, 2], [3, 4]]),
|
||||
[instance]
|
||||
)
|
||||
|
||||
def test_isnull(self):
|
||||
self.assertSequenceEqual(
|
||||
NullableIntegerArrayModel.objects.filter(field__isnull=True),
|
||||
|
@ -244,6 +258,73 @@ class TestQuerying(PostgreSQLTestCase):
|
|||
)
|
||||
|
||||
|
||||
class TestDateTimeExactQuerying(PostgreSQLTestCase):
|
||||
|
||||
def setUp(self):
|
||||
now = timezone.now()
|
||||
self.datetimes = [now]
|
||||
self.dates = [now.date()]
|
||||
self.times = [now.time()]
|
||||
self.objs = [
|
||||
DateTimeArrayModel.objects.create(
|
||||
datetimes=self.datetimes,
|
||||
dates=self.dates,
|
||||
times=self.times,
|
||||
)
|
||||
]
|
||||
|
||||
def test_exact_datetimes(self):
|
||||
self.assertSequenceEqual(
|
||||
DateTimeArrayModel.objects.filter(datetimes=self.datetimes),
|
||||
self.objs
|
||||
)
|
||||
|
||||
def test_exact_dates(self):
|
||||
self.assertSequenceEqual(
|
||||
DateTimeArrayModel.objects.filter(dates=self.dates),
|
||||
self.objs
|
||||
)
|
||||
|
||||
def test_exact_times(self):
|
||||
self.assertSequenceEqual(
|
||||
DateTimeArrayModel.objects.filter(times=self.times),
|
||||
self.objs
|
||||
)
|
||||
|
||||
|
||||
class TestOtherTypesExactQuerying(PostgreSQLTestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.ips = ['192.168.0.1', '::1']
|
||||
self.uuids = [uuid.uuid4()]
|
||||
self.decimals = [decimal.Decimal(1.25), 1.75]
|
||||
self.objs = [
|
||||
OtherTypesArrayModel.objects.create(
|
||||
ips=self.ips,
|
||||
uuids=self.uuids,
|
||||
decimals=self.decimals,
|
||||
)
|
||||
]
|
||||
|
||||
def test_exact_ip_addresses(self):
|
||||
self.assertSequenceEqual(
|
||||
OtherTypesArrayModel.objects.filter(ips=self.ips),
|
||||
self.objs
|
||||
)
|
||||
|
||||
def test_exact_uuids(self):
|
||||
self.assertSequenceEqual(
|
||||
OtherTypesArrayModel.objects.filter(uuids=self.uuids),
|
||||
self.objs
|
||||
)
|
||||
|
||||
def test_exact_decimals(self):
|
||||
self.assertSequenceEqual(
|
||||
OtherTypesArrayModel.objects.filter(decimals=self.decimals),
|
||||
self.objs
|
||||
)
|
||||
|
||||
|
||||
class TestChecks(PostgreSQLTestCase):
|
||||
|
||||
def test_field_checks(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue