Merge https://bitbucket.org/utek/alembic/branch/master into pr26
This commit is contained in:
commit
2a891e19da
|
@ -2,7 +2,7 @@ from sqlalchemy.ext.compiler import compiles
|
|||
|
||||
from .. import util
|
||||
from .impl import DefaultImpl
|
||||
from .base import alter_table, AddColumn, ColumnName, \
|
||||
from .base import alter_table, AddColumn, ColumnName, RenameTable,\
|
||||
format_table_name, format_column_name, ColumnNullable, alter_column,\
|
||||
format_server_default,ColumnDefault, format_type, ColumnType
|
||||
from sqlalchemy.sql.expression import ClauseElement, Executable
|
||||
|
@ -215,3 +215,9 @@ def visit_column_type(element, compiler, **kw):
|
|||
format_type(compiler, element.type_)
|
||||
)
|
||||
|
||||
@compiles(RenameTable, 'mssql')
|
||||
def visit_rename_table(element, compiler, **kw):
|
||||
return "EXEC sp_rename '%s', %s" % (
|
||||
format_table_name(compiler, element.table_name, element.schema),
|
||||
format_table_name(compiler, element.new_table_name, element.schema)
|
||||
)
|
||||
|
|
|
@ -193,6 +193,11 @@ class OpTest(TestCase):
|
|||
"EXEC sp_rename 't.c', c2, 'COLUMN'"
|
||||
)
|
||||
|
||||
def test_rename_table(self):
|
||||
context = op_fixture('mssql')
|
||||
op.rename_table('t1', 't2')
|
||||
context.assert_contains("EXEC sp_rename 't1', t2")
|
||||
|
||||
# TODO: when we add schema support
|
||||
#def test_alter_column_rename_mssql_schema(self):
|
||||
# context = op_fixture('mssql')
|
||||
|
|
Loading…
Reference in New Issue