summaryrefslogtreecommitdiff
path: root/tests/postgres_tests
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2025-11-21 17:55:28 +0100
committerGitHub <noreply@github.com>2025-11-21 17:55:28 +0100
commitbe0620b49fce5ddd179356575603c4160390965e (patch)
tree99ea116d002a8922d24e3ceb7f4dd1882d926794 /tests/postgres_tests
parent7e4c4f43f51e829e6378a0305bfda81479a368ab (diff)
Refs #36031 -- Added tests of DecimalRangeField __contains lookup with unbounded decimal ranges.
Co-authored-by: Aman Sharma <210100011@iitb.ac.in>
Diffstat (limited to 'tests/postgres_tests')
-rw-r--r--tests/postgres_tests/test_ranges.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/postgres_tests/test_ranges.py b/tests/postgres_tests/test_ranges.py
index 859eb0da79..f1c104e83b 100644
--- a/tests/postgres_tests/test_ranges.py
+++ b/tests/postgres_tests/test_ranges.py
@@ -304,6 +304,25 @@ class TestQuerying(PostgreSQLTestCase):
[self.objs[0]],
)
+ def test_decimal_contains_range(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, "(]")),
+ ]
+ )
+ for contains, objs in [
+ (199, [decimals[1]]),
+ (1, [decimals[0]]),
+ (15, [decimals[1], decimals[3]]),
+ ]:
+ with self.subTest(decimal_contains=contains):
+ self.assertSequenceEqual(
+ RangesModel.objects.filter(decimals__contains=contains), objs
+ )
+
def test_contained_by(self):
self.assertSequenceEqual(
RangesModel.objects.filter(ints__contained_by=NumericRange(0, 20)),