summaryrefslogtreecommitdiff
path: root/test/sql/test_defaults.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 /test/sql/test_defaults.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 'test/sql/test_defaults.py')
-rw-r--r--test/sql/test_defaults.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/test/sql/test_defaults.py b/test/sql/test_defaults.py
index 2750568d8..4a6ebd0c8 100644
--- a/test/sql/test_defaults.py
+++ b/test/sql/test_defaults.py
@@ -294,13 +294,6 @@ class DefaultObjectTest(fixtures.TestBase):
Column("col3", Integer, Sequence("foo"), server_default="x"),
Column("col4", Integer, ColumnDefault("x"), DefaultClause("y")),
Column(
- "col4",
- Integer,
- ColumnDefault("x"),
- DefaultClause("y"),
- DefaultClause("y", for_update=True),
- ),
- Column(
"col5",
Integer,
ColumnDefault("x"),
@@ -326,6 +319,16 @@ class DefaultObjectTest(fixtures.TestBase):
onupdate="z",
),
)
+ tbl.append_column(
+ Column(
+ "col4",
+ Integer,
+ ColumnDefault("x"),
+ DefaultClause("y"),
+ DefaultClause("y", for_update=True),
+ ),
+ replace_existing=True,
+ )
has_(tbl, "col1", "default")
has_(tbl, "col2", "default", "server_default")
has_(tbl, "col3", "default", "server_default")