summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/engine/reflection.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2020-09-03 14:14:39 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2020-10-12 13:52:06 -0400
commit9e82f32f274e649b04740c819d21ba232c89cfff (patch)
tree15ba969d68aa914ffff413d1db3d2697761ba247 /lib/sqlalchemy/engine/reflection.py
parenta3e2eb7c3c3fe6b2bebd14a7e9d661b2b4519d1f (diff)
downloadsqlalchemy-9e82f32f274e649b04740c819d21ba232c89cfff.tar.gz
Deprecate duplicated column names in Table definition
The :class:`_schema.Table` class now raises a deprecation warning when columns with the same name are defined. To replace a column a new parameter :paramref:`_schema.Table.append_column.replace_existing` was added to the :meth:`_schema.Table.append_column` method. The :meth:`_expression.ColumnCollection.contains_column` will now raises an error when called with a string, suggesting the caller to use ``in`` instead. Co-authored-by: Federico Caselli <cfederico87@gmail.com> Change-Id: I1d58c8ebe081079cb669e7ead60886ffc1b1a7f5
Diffstat (limited to 'lib/sqlalchemy/engine/reflection.py')
-rw-r--r--lib/sqlalchemy/engine/reflection.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/sqlalchemy/engine/reflection.py b/lib/sqlalchemy/engine/reflection.py
index 92a85df2e..6af74d052 100644
--- a/lib/sqlalchemy/engine/reflection.py
+++ b/lib/sqlalchemy/engine/reflection.py
@@ -898,7 +898,7 @@ class Inspector(object):
if col.key in table.primary_key:
col.primary_key = True
- table.append_column(col)
+ table.append_column(col, replace_existing=True)
def _reflect_col_sequence(self, col_d, colargs):
if "sequence" in col_d: