diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-09-03 14:14:39 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-10-12 13:52:06 -0400 |
commit | 9e82f32f274e649b04740c819d21ba232c89cfff (patch) | |
tree | 15ba969d68aa914ffff413d1db3d2697761ba247 /test/base/test_utils.py | |
parent | a3e2eb7c3c3fe6b2bebd14a7e9d661b2b4519d1f (diff) | |
download | sqlalchemy-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/base/test_utils.py')
-rw-r--r-- | test/base/test_utils.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/base/test_utils.py b/test/base/test_utils.py index 843d36b71..876cb7a44 100644 --- a/test/base/test_utils.py +++ b/test/base/test_utils.py @@ -460,6 +460,23 @@ class ColumnCollectionCommon(testing.AssertsCompiledSQL): is_true(cc.contains_column(c1)) is_false(cc.contains_column(c3)) + def test_contains_column_not_column(self): + c1, c2, c3 = sql.column("c1"), sql.column("c2"), sql.column("c3") + cc = self._column_collection(columns=[("c1", c1), ("c2", c2)]) + + is_false(cc.contains_column(c3 == 2)) + + with testing.expect_raises_message( + exc.ArgumentError, + "contains_column cannot be used with string arguments", + ): + cc.contains_column("c1") + with testing.expect_raises_message( + exc.ArgumentError, + "contains_column cannot be used with string arguments", + ): + cc.contains_column("foo") + def test_in(self): col1 = sql.column("col1") cc = self._column_collection( |