summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/base.py
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2022-12-04 17:25:44 +0000
committerGerrit Code Review <gerrit@ci3.zzzcomputing.com>2022-12-04 17:25:44 +0000
commit4a9e448d9e5024003a72b6b53337b2bc42905042 (patch)
tree2c1ce9d3a1cdf9459a69d4755e9bd68c5391a13f /lib/sqlalchemy/sql/base.py
parent272b400f137d62e6be31084e2d91688102187a48 (diff)
parent1284fa377e53f03cec061d7af16f269ad73fa7b9 (diff)
downloadsqlalchemy-4a9e448d9e5024003a72b6b53337b2bc42905042.tar.gz
Merge "disallow same-named columns, unchecked replacement in Table" into main
Diffstat (limited to 'lib/sqlalchemy/sql/base.py')
-rw-r--r--lib/sqlalchemy/sql/base.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/sqlalchemy/sql/base.py b/lib/sqlalchemy/sql/base.py
index fc80334e8..0b96e5bbf 100644
--- a/lib/sqlalchemy/sql/base.py
+++ b/lib/sqlalchemy/sql/base.py
@@ -1969,7 +1969,11 @@ class DedupeColumnCollection(ColumnCollection[str, _NAMEDCOL]):
# delete higher index
del self._index[len(self._collection)]
- def replace(self, column: _NAMEDCOL) -> None:
+ def replace(
+ self,
+ column: _NAMEDCOL,
+ extra_remove: Optional[Iterable[_NAMEDCOL]] = None,
+ ) -> None:
"""add the given column to this collection, removing unaliased
versions of this column as well as existing columns with the
same key.
@@ -1986,7 +1990,10 @@ class DedupeColumnCollection(ColumnCollection[str, _NAMEDCOL]):
"""
- remove_col = set()
+ if extra_remove:
+ remove_col = set(extra_remove)
+ else:
+ remove_col = set()
# remove up to two columns based on matches of name as well as key
if column.name in self._index and column.key != column.name:
other = self._index[column.name][1]