You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Migrated issue, originally created by Michael Bayer (@zzzeek)
diff --git a/tests/test_mysql.py b/tests/test_mysql.py
index 2dc8838..7600ebf 100644
--- a/tests/test_mysql.py
+++ b/tests/test_mysql.py
@@ -1,4 +1,4 @@
-from sqlalchemy import Integer, func
+from sqlalchemy import Integer, func, Boolean
from alembic.testing.fixtures import TestBase
from alembic.testing import config
from sqlalchemy import TIMESTAMP, MetaData, Table, Column, text
@@ -102,6 +102,17 @@ class MySQLOpTest(TestBase):
'ALTER TABLE t ALTER COLUMN c DROP DEFAULT'
)
+ def test_alter_column_remove_schematype(self):
+ context = op_fixture('mysql')
+ op.alter_column(
+ "t", "c",
+ type_=Integer,
+ existing_type=Boolean(create_constraint=True, name="ck1"),
+ server_default=None)
+ context.assert_(
+ 'ALTER TABLE t MODIFY c INTEGER NULL'
+ )
+
def test_alter_column_modify_default(self):
context = op_fixture('mysql')
# notice we dont need the existing type on this one...
stack:
#!
Traceback (most recent call last):
File "/home/classic/dev/alembic/tests/test_mysql.py", line 111, in test_alter_column_remove_schematype
server_default=None)
File "<string>", line 8, in alter_column
File "<string>", line 3, in alter_column
File "/home/classic/dev/alembic/alembic/operations/ops.py", line 1414, in alter_column
return operations.invoke(alt)
File "/home/classic/dev/alembic/alembic/operations/base.py", line 318, in invoke
return fn(self, operation)
File "/home/classic/dev/alembic/alembic/operations/toimpl.py", line 41, in alter_column
operations.impl.drop_constraint(constraint)
File "/home/classic/dev/alembic/alembic/ddl/impl.py", line 183, in drop_constraint
self._exec(schema.DropConstraint(const))
File "/home/classic/dev/alembic/alembic/ddl/impl.py", line 118, in _exec
return conn.execute(construct, *multiparams, **params)
File "/home/classic/dev/alembic/alembic/testing/fixtures.py", line 151, in execute
sql = text_type(stmt.compile(dialect=ctx_dialect))
File "<string>", line 1, in <lambda>
File "/home/classic/dev/sqlalchemy/lib/sqlalchemy/sql/elements.py", line 433, in compile
return self._compiler(dialect, bind=bind, **kw)
File "/home/classic/dev/sqlalchemy/lib/sqlalchemy/sql/ddl.py", line 26, in _compiler
return dialect.ddl_compiler(dialect, self, **kw)
File "/home/classic/dev/sqlalchemy/lib/sqlalchemy/sql/compiler.py", line 206, in __init__
self.string = self.process(self.statement, **compile_kwargs)
File "/home/classic/dev/sqlalchemy/lib/sqlalchemy/sql/compiler.py", line 229, in process
return obj._compiler_dispatch(self, **kwargs)
File "/home/classic/dev/sqlalchemy/lib/sqlalchemy/ext/compiler.py", line 423, in <lambda>
lambda *arg, **kw: existing(*arg, **kw))
File "/home/classic/dev/sqlalchemy/lib/sqlalchemy/ext/compiler.py", line 461, in __call__
return fn(element, compiler, **kw)
File "/home/classic/dev/alembic/alembic/ddl/mysql.py", line 312, in _mysql_drop_constraint
"MySQL does not support CHECK constraints.")
NotImplementedError: MySQL does not support CHECK constraints.
The text was updated successfully, but these errors were encountered:
Repaired batch migration support for "schema" types which generate
constraints, in particular the Boolean datatype which generates
a CHECK constraint. Previously, an alter column operation with this
type would fail to correctly accommodate for the CHECK constraint
on change both from and to this type. In the former case the operation
would fail entirely, in the latter, the CHECK constraint would
not get generated. Both of these issues are repaired.
fixes cant change type of boolean w/ batch #354
Changing a schema type such as Boolean to a non-schema type would
emit a drop constraint operation which emits NotImplementedError for
the MySQL dialect. This drop constraint operation is now skipped when
the constraint originates from a schema type.
fixes cant' change mysql schematype due to DROP constraint #355
Migrated issue, originally created by Michael Bayer (@zzzeek)
stack:
The text was updated successfully, but these errors were encountered: