summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2023-05-16 08:55:51 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2023-05-16 13:50:09 -0400
commit513ab5d8029eaeb8cccee8eb931774d13a08d726 (patch)
tree823093e2f9acc729ae5f86ff7924ba2defa3d91b /tests
parentf983e1d1442070bfc35ce1c19379221c1baf54cf (diff)
downloadalembic-513ab5d8029eaeb8cccee8eb931774d13a08d726.tar.gz
restore drop_index.table_name, drop_constraint.type_ as positional
These two API changes were identified as having legacy use patterns and should be revisited using a deprecation warning for removal in either 1.12 or 1.13. Add documentation re: Alembic not using semver, fix incorrect calling signature example in batch documentation. Change-Id: I33dc5a8d058bcce77591bb037ae964e626a3387f Fixes: #1243 Fixes: #1245
Diffstat (limited to 'tests')
-rw-r--r--tests/test_batch.py13
-rw-r--r--tests/test_mssql.py6
-rw-r--r--tests/test_mysql.py6
-rw-r--r--tests/test_op.py22
4 files changed, 47 insertions, 0 deletions
diff --git a/tests/test_batch.py b/tests/test_batch.py
index 66d59fd..5920cdf 100644
--- a/tests/test_batch.py
+++ b/tests/test_batch.py
@@ -1783,6 +1783,19 @@ class BatchRoundTripTest(TestBase):
ck_consts = inspect(self.conn).get_check_constraints("ck_table")
eq_(ck_consts, [])
+ @config.requirements.check_constraint_reflection
+ def test_drop_ck_constraint_legacy_type(self):
+ self._ck_constraint_fixture()
+
+ with self.op.batch_alter_table(
+ "ck_table", recreate="always"
+ ) as batch_op:
+ # matches the docs that were written for this originally
+ batch_op.drop_constraint("ck", "check")
+
+ ck_consts = inspect(self.conn).get_check_constraints("ck_table")
+ eq_(ck_consts, [])
+
@config.requirements.unnamed_constraints
def test_drop_foreign_key(self):
bar = Table(
diff --git a/tests/test_mssql.py b/tests/test_mssql.py
index b785e2f..693ab57 100644
--- a/tests/test_mssql.py
+++ b/tests/test_mssql.py
@@ -161,6 +161,12 @@ class OpTest(TestBase):
op.drop_index("my_idx", table_name="my_table")
context.assert_contains("DROP INDEX my_idx ON my_table")
+ def test_drop_index_w_tablename_legacy(self):
+ """#1243"""
+ context = op_fixture("mssql")
+ op.drop_index("my_idx", "my_table")
+ context.assert_contains("DROP INDEX my_idx ON my_table")
+
def test_drop_column_w_default(self):
context = op_fixture("mssql")
op.drop_column("t1", "c1", mssql_drop_default=True)
diff --git a/tests/test_mysql.py b/tests/test_mysql.py
index fd3b185..c3ac966 100644
--- a/tests/test_mysql.py
+++ b/tests/test_mysql.py
@@ -399,6 +399,12 @@ class MySQLOpTest(TestBase):
op.drop_constraint("f1", "t1", type_="foreignkey")
context.assert_("ALTER TABLE t1 DROP FOREIGN KEY f1")
+ def test_drop_fk_legacy(self):
+ """#1245"""
+ context = op_fixture("mysql")
+ op.drop_constraint("f1", "t1", "foreignkey")
+ context.assert_("ALTER TABLE t1 DROP FOREIGN KEY f1")
+
def test_drop_fk_quoted(self):
context = op_fixture("mysql")
op.drop_constraint("MyFk", "MyTable", type_="foreignkey")
diff --git a/tests/test_op.py b/tests/test_op.py
index 35adeaf..6aca753 100644
--- a/tests/test_op.py
+++ b/tests/test_op.py
@@ -806,6 +806,17 @@ class OpTest(TestBase):
op.drop_constraint("foo_bar_bat", "t1")
context.assert_("ALTER TABLE t1 DROP CONSTRAINT foo_bar_bat")
+ def test_drop_constraint_type(self):
+ context = op_fixture()
+ op.drop_constraint("foo_bar_bat", "t1", type_="foreignkey")
+ context.assert_("ALTER TABLE t1 DROP CONSTRAINT foo_bar_bat")
+
+ def test_drop_constraint_legacy_type(self):
+ """#1245"""
+ context = op_fixture()
+ op.drop_constraint("foo_bar_bat", "t1", "foreignkey")
+ context.assert_("ALTER TABLE t1 DROP CONSTRAINT foo_bar_bat")
+
def test_drop_constraint_schema(self):
context = op_fixture()
op.drop_constraint("foo_bar_bat", "t1", schema="foo")
@@ -856,6 +867,17 @@ class OpTest(TestBase):
op.drop_index("ik_test")
context.assert_("DROP INDEX ik_test")
+ def test_drop_index_w_tablename(self):
+ context = op_fixture()
+ op.drop_index("ik_test", table_name="the_table")
+ context.assert_("DROP INDEX ik_test")
+
+ def test_drop_index_w_tablename_legacy(self):
+ """#1243"""
+ context = op_fixture()
+ op.drop_index("ik_test", "the_table")
+ context.assert_("DROP INDEX ik_test")
+
def test_drop_index_schema(self):
context = op_fixture()
op.drop_index("ik_test", schema="foo")