mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #29916 -- Added lower_inc, lower_inf, upper_inc, and upper_inf lookups for RangeFields.
Co-Authored-By: Mariusz Felisiak <felisiak.mariusz@gmail.com>
This commit is contained in:
parent
efc3e32d6d
commit
24b9f50823
4 changed files with 112 additions and 0 deletions
|
@ -296,6 +296,30 @@ class TestQuerying(PostgreSQLTestCase):
|
|||
[self.objs[0], self.objs[1]],
|
||||
)
|
||||
|
||||
def test_bound_type(self):
|
||||
decimals = RangesModel.objects.bulk_create([
|
||||
RangesModel(decimals=NumericRange(None, 10)),
|
||||
RangesModel(decimals=NumericRange(10, None)),
|
||||
RangesModel(decimals=NumericRange(5, 15)),
|
||||
RangesModel(decimals=NumericRange(5, 15, '(]')),
|
||||
])
|
||||
tests = [
|
||||
('lower_inc', True, [decimals[1], decimals[2]]),
|
||||
('lower_inc', False, [decimals[0], decimals[3]]),
|
||||
('lower_inf', True, [decimals[0]]),
|
||||
('lower_inf', False, [decimals[1], decimals[2], decimals[3]]),
|
||||
('upper_inc', True, [decimals[3]]),
|
||||
('upper_inc', False, [decimals[0], decimals[1], decimals[2]]),
|
||||
('upper_inf', True, [decimals[1]]),
|
||||
('upper_inf', False, [decimals[0], decimals[2], decimals[3]]),
|
||||
]
|
||||
for lookup, filter_arg, excepted_result in tests:
|
||||
with self.subTest(lookup=lookup, filter_arg=filter_arg):
|
||||
self.assertSequenceEqual(
|
||||
RangesModel.objects.filter(**{'decimals__%s' % lookup: filter_arg}),
|
||||
excepted_result,
|
||||
)
|
||||
|
||||
|
||||
class TestQueryingWithRanges(PostgreSQLTestCase):
|
||||
def test_date_range(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue