diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-05-01 11:19:54 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-05-01 11:19:54 -0400 |
commit | 494ac8d84a4e827fcf7dc117b84ba76f442d60a2 (patch) | |
tree | 57b5ae7a873ea5eab423aa0642dff3aa1c9d9f1b /tests/test_mysql.py | |
parent | 7835a323a7e41558989afcb2eeaa73b968dd9e34 (diff) | |
download | alembic-494ac8d84a4e827fcf7dc117b84ba76f442d60a2.tar.gz |
- [bug] Added "type" argument to op.drop_constraint(),
and implemented full constraint drop support for
MySQL. CHECK and undefined raise an error.
MySQL needs the constraint type
in order to emit a DROP CONSTRAINT. #44
Diffstat (limited to 'tests/test_mysql.py')
-rw-r--r-- | tests/test_mysql.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/test_mysql.py b/tests/test_mysql.py index 499dec7..4c4a357 100644 --- a/tests/test_mysql.py +++ b/tests/test_mysql.py @@ -40,3 +40,42 @@ def test_col_alter_type_required(): "All MySQL ALTER COLUMN operations require the existing type.", op.alter_column, 't1', 'c1', nullable=False, server_default="q" ) + +def test_drop_fk(): + context = op_fixture('mysql') + op.drop_constraint("f1", "t1", "foreignkey") + context.assert_( + "ALTER TABLE t1 DROP FOREIGN KEY f1" + ) + +def test_drop_unique(): + context = op_fixture('mysql') + op.drop_constraint("f1", "t1", "unique") + context.assert_( + "ALTER TABLE t1 DROP INDEX f1" + ) + +def test_drop_check(): + context = op_fixture('mysql') + assert_raises_message( + NotImplementedError, + "MySQL does not support CHECK constraints.", + op.drop_constraint, "f1", "t1", "check" + ) + +def test_drop_unknown(): + context = op_fixture('mysql') + assert_raises_message( + TypeError, + "'type' can be one of 'check', 'foreignkey', 'unique', None", + op.drop_constraint, "f1", "t1", "typo" + ) + +def test_drop_generic_constraint(): + context = op_fixture('mysql') + assert_raises_message( + NotImplementedError, + "No generic 'DROP CONSTRAINT' in MySQL - please " + "specify constraint type", + op.drop_constraint, "f1", "t1" + )
\ No newline at end of file |