summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql
diff options
context:
space:
mode:
authorLele Gaifax <lele@metapensiero.it>2022-12-04 20:51:13 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2022-12-05 11:51:26 -0500
commit3da784be647125f8727a92d1e386155e1f53c671 (patch)
tree3ee33277558ec4dcd1b38288be33939dcc25c5b5 /test/dialect/postgresql
parent9058593e0b28cee0211251de6604e4601ff69a00 (diff)
downloadsqlalchemy-3da784be647125f8727a92d1e386155e1f53c671.tar.gz
Add compatibility properties to Range; implement pep-484
This adds a bunch of properties to new PG Range class for compatibility with other implementations, providing a more similar API to access emptiness and bounds status. The naming conventions here derive from PostgreSQL itself, see https://www.postgresql.org/docs/9.3/functions-range.html . pep-484 also implemented by Mike, as this is a pretty type-intensive module. Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Closes: #8927 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8927 Pull-request-sha: 8b9e7b7e3345673b43aeabd7ec88b88dc3cfa7eb Change-Id: I0b1d49311517ee1cc1377a974ed0a860ea5756e4
Diffstat (limited to 'test/dialect/postgresql')
-rw-r--r--test/dialect/postgresql/test_types.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/dialect/postgresql/test_types.py b/test/dialect/postgresql/test_types.py
index ec9bcbae9..dcde497b4 100644
--- a/test/dialect/postgresql/test_types.py
+++ b/test/dialect/postgresql/test_types.py
@@ -3996,6 +3996,24 @@ class _RangeComparisonFixtures(_RangeTests):
is_false(range_.contains(values["rh"]))
+ def test_compatibility_accessors(self):
+ range_ = self._data_obj()
+
+ is_true(range_.lower_inc)
+ is_false(range_.upper_inc)
+ is_false(Range(lower=range_.lower, bounds="()").lower_inc)
+ is_true(Range(upper=range_.upper, bounds="(]").upper_inc)
+
+ is_false(range_.lower_inf)
+ is_false(range_.upper_inf)
+ is_false(Range(empty=True).lower_inf)
+ is_false(Range(empty=True).upper_inf)
+ is_true(Range().lower_inf)
+ is_true(Range().upper_inf)
+
+ is_false(range_.isempty)
+ is_true(Range(empty=True).isempty)
+
def test_contains_value(
self, connection, bounds_obj_combinations, value_combinations
):