From: Daniele Varrazzo Date: Wed, 9 Jun 2021 15:43:05 +0000 (+0100) Subject: Add Range.bounds attribute X-Git-Tag: 3.0.dev0~18^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=382d9f3c6b68def740bf6db02817ebfee573844e;p=thirdparty%2Fpsycopg.git Add Range.bounds attribute --- 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