MSSQL to not include the keyword "TYPE".
"scripts/alembic" as setuptools creates this
for us. [#22]
+- [bug] Fixed alteration of column type on
+ MSSQL to not include the keyword "TYPE".
+
0.1.1
=====
- [bug] Clean up file write operations so that
from alembic.ddl.impl import DefaultImpl
from alembic.ddl.base import alter_table, AddColumn, ColumnName, \
format_table_name, format_column_name, ColumnNullable, alter_column,\
- format_server_default,ColumnDefault, format_type
+ format_server_default,ColumnDefault, format_type, ColumnType
from alembic import util
from sqlalchemy.ext.compiler import compiles
format_column_name(compiler, element.newname)
)
+@compiles(ColumnType, 'mssql')
+def visit_column_type(element, compiler, **kw):
+ return "%s %s %s" % (
+ alter_table(compiler, element.table_name, element.schema),
+ alter_column(compiler, element.column_name),
+ format_type(compiler, element.type_)
+ )
"EXEC sp_rename 't.c', 'x', 'COLUMN'"
)
+ def test_alter_column_new_type(self):
+ context = op_fixture('mssql')
+ op.alter_column("t", "c", type_=Integer)
+ context.assert_(
+ 'ALTER TABLE t ALTER COLUMN c INTEGER'
+ )
+
def test_drop_column_w_default(self):
context = op_fixture('mssql')
op.drop_column('t1', 'c1', mssql_drop_default=True)
context = op_fixture('mssql')
op.alter_column("t", "c", type_=Boolean())
context.assert_(
- 'ALTER TABLE t ALTER COLUMN c TYPE BIT',
+ 'ALTER TABLE t ALTER COLUMN c BIT',
'ALTER TABLE t ADD CHECK (c IN (0, 1))'
)
context = op_fixture('mssql')
op.alter_column("t", "c", type_=Boolean(name="xyz"))
context.assert_(
- 'ALTER TABLE t ALTER COLUMN c TYPE BIT',
+ 'ALTER TABLE t ALTER COLUMN c BIT',
'ALTER TABLE t ADD CONSTRAINT xyz CHECK (c IN (0, 1))'
)
op.alter_column("t", "c", type_=String(10), existing_type=Boolean(name="xyz"))
context.assert_(
'ALTER TABLE t DROP CONSTRAINT xyz',
- 'ALTER TABLE t ALTER COLUMN c TYPE VARCHAR(10)'
+ 'ALTER TABLE t ALTER COLUMN c VARCHAR(10)'
)
def test_add_foreign_key():