summaryrefslogtreecommitdiff
path: root/tests/test_batch.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-02-01 09:12:17 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2022-02-01 09:33:12 -0500
commit8c0990988d880e0e56a32403a912b9d590cde8d2 (patch)
treeac453755eeb2a6f9da514ed4d30c4eaeaf29da29 /tests/test_batch.py
parent52dee10f107a5d9295236fa62dc7094dc3f0b023 (diff)
downloadalembic-8c0990988d880e0e56a32403a912b9d590cde8d2.tar.gz
resolve for variant before testing for schema type
Fixed regression where usage of a ``with_variant()`` datatype in conjunction with the ``existing_type`` option of ``op.alter_column()`` under batch mode would lead to an internal exception. note this exception would only occur under 1.x, under 2.0 the new variant architecture would have prevented this problem, however it is best here that the ultimate variant type is unwrapped in the case that we have a plain type with a schema type as a variant. also sqla 1.3 needs pytest < 7 to run correctly Change-Id: I0f5480f97f014e707b8bd4e70f8495d3bd27fd21 Fixes: #982
Diffstat (limited to 'tests/test_batch.py')
-rw-r--r--tests/test_batch.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_batch.py b/tests/test_batch.py
index 700056a..f0bbd75 100644
--- a/tests/test_batch.py
+++ b/tests/test_batch.py
@@ -1138,6 +1138,30 @@ class CopyFromTest(TestBase):
"ALTER TABLE _alembic_tmp_foo RENAME TO foo",
)
+ def test_change_name_from_existing_variant_type(self):
+ """test #982"""
+ context = self._fixture()
+ self.table.append_column(
+ Column("y", Text().with_variant(Text(10000), "mysql"))
+ )
+
+ with self.op.batch_alter_table(
+ "foo", copy_from=self.table
+ ) as batch_op:
+ batch_op.alter_column(
+ column_name="y",
+ new_column_name="q",
+ existing_type=Text().with_variant(Text(10000), "mysql"),
+ )
+ context.assert_(
+ "CREATE TABLE _alembic_tmp_foo (id INTEGER NOT NULL, "
+ "data VARCHAR(50), x INTEGER, q TEXT, PRIMARY KEY (id))",
+ "INSERT INTO _alembic_tmp_foo (id, data, x, q) "
+ "SELECT foo.id, foo.data, foo.x, foo.y FROM foo",
+ "DROP TABLE foo",
+ "ALTER TABLE _alembic_tmp_foo RENAME TO foo",
+ )
+
def test_change_type_to_schematype(self):
context = self._fixture()
self.table.append_column(Column("y", Integer))