diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-03-04 10:54:03 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-03-04 10:54:03 -0500 |
commit | bd34d2e4e4daee6e25d3c8a9a43299e883cb8da3 (patch) | |
tree | 3ed66d63a3765bc4dea8b72b25c7b38ea5abd350 /tests/test_op.py | |
parent | 763103407a22f68450c08d731dc7bbc312967dcf (diff) | |
download | alembic-bd34d2e4e4daee6e25d3c8a9a43299e883cb8da3.tar.gz |
Adjust mssql accommodate existing_type and type
Fixed bug where the "existing_type" parameter, which the MSSQL dialect
requires in order to change the nullability of a column in the absence of
also changing the column type, would cause an ALTER COLUMN operation to
incorrectly render a second ALTER statement without the nullability if a
new type were also present, as the MSSQL-specific contract did not
anticipate all three of "nullability", "type_" and "existing_type" being
sent at the same time.
Change-Id: Ia95b6c3e9276cc067fd773928f9678ab429d5670
Fixes: #812
Diffstat (limited to 'tests/test_op.py')
-rw-r--r-- | tests/test_op.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test_op.py b/tests/test_op.py index 58a6a86..93bba28 100644 --- a/tests/test_op.py +++ b/tests/test_op.py @@ -462,6 +462,31 @@ class OpTest(TestBase): "ALTER TABLE foo.t ADD CONSTRAINT xyz CHECK (c IN (0, 1))", ) + @combinations((True,), (False,), argnames="pass_existing_type") + @combinations((True,), (False,), argnames="change_nullability") + def test_generic_alter_column_type_and_nullability( + self, pass_existing_type, change_nullability + ): + # this test is also on the mssql dialect in test_mssql + context = op_fixture() + + args = dict(type_=Integer) + if pass_existing_type: + args["existing_type"] = String(15) + + if change_nullability: + args["nullable"] = False + + op.alter_column("t", "c", **args) + + if change_nullability: + context.assert_( + "ALTER TABLE t ALTER COLUMN c SET NOT NULL", + "ALTER TABLE t ALTER COLUMN c TYPE INTEGER", + ) + else: + context.assert_("ALTER TABLE t ALTER COLUMN c TYPE INTEGER") + def test_alter_column_schema_type_existing_type(self): context = op_fixture("mssql", native_boolean=False) op.alter_column( |