From 6ccd54c7ea704c9f61d3aac25a8a392462638cfd Mon Sep 17 00:00:00 2001 From: Lele Gaifax Date: Mon, 7 Nov 2022 19:23:34 +0100 Subject: [PATCH] Rename AbstractRange.__add__() to union(), make __add__ an alias --- lib/sqlalchemy/dialects/postgresql/ranges.py | 4 +++- test/dialect/postgresql/test_types.py | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/sqlalchemy/dialects/postgresql/ranges.py b/lib/sqlalchemy/dialects/postgresql/ranges.py index c1552874a3..5631fea220 100644 --- a/lib/sqlalchemy/dialects/postgresql/ranges.py +++ b/lib/sqlalchemy/dialects/postgresql/ranges.py @@ -536,13 +536,15 @@ class AbstractRange(sqltypes.TypeEngine): """ return self.expr.op("-|-", is_comparison=True)(other) - def __add__(self, other): + def union(self, other): """Range expression. Returns the union of the two ranges. Will raise an exception if the resulting range is not contiguous. """ return self.expr.op("+")(other) + __add__ = union + class AbstractRangeImpl(AbstractRange): """marker for AbstractRange that will apply a subclass-specific diff --git a/test/dialect/postgresql/test_types.py b/test/dialect/postgresql/test_types.py index ef2972a0b8..e66a159955 100644 --- a/test/dialect/postgresql/test_types.py +++ b/test/dialect/postgresql/test_types.py @@ -3834,6 +3834,12 @@ class _RangeTypeCompilation(AssertsCompiledSQL, fixtures.TestBase): self.col.type, ) + self._test_clause( + self.col.union(self._data_str()), + "data_table.range + %(range_1)s", + self.col.type, + ) + def test_intersection(self): self._test_clause( self.col * self.col, -- 2.47.3