]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Rename AbstractRange.__add__() to union(), make __add__ an alias
authorLele Gaifax <lele@metapensiero.it>
Mon, 7 Nov 2022 18:23:34 +0000 (19:23 +0100)
committerLele Gaifax <lele@metapensiero.it>
Mon, 7 Nov 2022 18:42:48 +0000 (19:42 +0100)
lib/sqlalchemy/dialects/postgresql/ranges.py
test/dialect/postgresql/test_types.py

index c1552874a31111ecf11097ab2798e048f4e71e97..5631fea220d5109508df91136d1a7bec987010b5 100644 (file)
@@ -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
index ef2972a0b880db8d60c5d4e129c169b5b4bac42d..e66a159955f6474663ffe1be975e208f42dbf8e4 100644 (file)
@@ -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,