diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-11-29 19:01:31 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-11-29 19:01:31 -0500 |
commit | a0f0cd381dc5bb4b780fa239df277891b2236e34 (patch) | |
tree | 2c277115259d0b087e2ed1763b1857690ab3d683 /tests/test_mssql.py | |
parent | b91de33b0786905e053fe3fadbb19b86c9b4b333 (diff) | |
download | alembic-a0f0cd381dc5bb4b780fa239df277891b2236e34.tar.gz |
implement server default, nullability for SQL server
Diffstat (limited to 'tests/test_mssql.py')
-rw-r--r-- | tests/test_mssql.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/test_mssql.py b/tests/test_mssql.py index 9a4c844..883590f 100644 --- a/tests/test_mssql.py +++ b/tests/test_mssql.py @@ -118,6 +118,35 @@ class OpTest(TestCase): op.alter_column, "t", "c", nullable=False ) + def test_alter_add_server_default(self): + context = op_fixture('mssql') + op.alter_column("t", "c", server_default="5") + context.assert_( + "ALTER TABLE t ADD DEFAULT '5' FOR c" + ) + + def test_alter_replace_server_default(self): + context = op_fixture('mssql') + op.alter_column("t", "c", server_default="5", existing_server_default="6") + context.assert_contains("exec('alter table t drop constraint ' + @const_name_1)") + context.assert_contains( + "ALTER TABLE t ADD DEFAULT '5' FOR c" + ) + + def test_alter_remove_server_default(self): + context = op_fixture('mssql') + op.alter_column("t", "c", server_default=None) + context.assert_contains("exec('alter table t drop constraint ' + @const_name_1)") + + def test_alter_do_everything(self): + context = op_fixture('mssql') + op.alter_column("t", "c", name="c2", nullable=True, type_=Integer, server_default="5") + context.assert_( + 'ALTER TABLE t ALTER COLUMN c INTEGER NULL', + "ALTER TABLE t ADD DEFAULT '5' FOR c", + "EXEC sp_rename 't.c', 'c2', 'COLUMN'" + ) + # TODO: when we add schema support #def test_alter_column_rename_mssql_schema(self): # context = op_fixture('mssql') |