From 382d9f3c6b68def740bf6db02817ebfee573844e Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Wed, 9 Jun 2021 16:43:05 +0100 Subject: [PATCH] Add Range.bounds attribute --- psycopg3/psycopg3/types/range.py | 5 +++++ tests/types/test_range.py | 1 + 2 files changed, 6 insertions(+) diff --git a/psycopg3/psycopg3/types/range.py b/psycopg3/psycopg3/types/range.py index 0ebecbd55..bbc5c1e5d 100644 --- a/psycopg3/psycopg3/types/range.py +++ b/psycopg3/psycopg3/types/range.py @@ -92,6 +92,11 @@ class Range(Generic[T]): """The upper bound of the range. `!None` if empty or unbound.""" return self._upper + @property + def bounds(self) -> str: + """The bounds string (two characters from '[', '(', ']', ')').""" + return self._bounds + @property def isempty(self) -> bool: """`!True` if the range is empty.""" diff --git a/tests/types/test_range.py b/tests/types/test_range.py index b8e161746..285d02a62 100644 --- a/tests/types/test_range.py +++ b/tests/types/test_range.py @@ -289,6 +289,7 @@ class TestRangeObject: ("[]", True, True), ]: r = Range(10, 20, bounds) + assert r.bounds == bounds assert r.lower == 10 assert r.upper == 20 assert not r.isempty -- 2.47.3