--- /dev/null
+.. change::
+ :tags: bug, sql, oracle, mysql
+ :tickets: 4436
+
+ Fixed issue where the DDL emitted for :class:`.DropTableComment`, which
+ will be used by an upcoming version of Alembic, was incorrect for the MySQL
+ and Oracle databases.
),
)
+ def visit_drop_table_comment(self, create):
+ return "ALTER TABLE %s COMMENT ''" % (
+ self.preparer.format_table(create.element)
+ )
+
def visit_set_column_comment(self, create):
return "ALTER TABLE %s CHANGE %s %s" % (
self.preparer.format_table(create.element.table),
return text
+ def visit_drop_table_comment(self, drop):
+ return "COMMENT ON TABLE %s IS ''" % self.preparer.format_table(
+ drop.element
+ )
+
def visit_create_index(self, create):
index = create.element
self._verify_index_table(index)
class DropTableComment(_CreateDropBase):
- """Represent a COMMENT ON TABLE IS NULL statement."""
+ """Represent a COMMENT ON TABLE '' statement.
+
+ Note this varies a lot across database backends.
+
+ """
__visit_name__ = "drop_table_comment"
from ..assertions import eq_
from ..config import requirements
from ... import Column
+from ... import inspect
from ... import Integer
+from ... import schema
from ... import String
from ... import Table
table.create(config.db, checkfirst=False)
self._simple_roundtrip(table)
+ @requirements.comment_reflection
+ @util.provide_metadata
+ def test_add_table_comment(self):
+ table = self._simple_fixture()
+ table.create(config.db, checkfirst=False)
+ table.comment = "a comment"
+ config.db.execute(schema.SetTableComment(table))
+ eq_(
+ inspect(config.db).get_table_comment("test_table"),
+ {"text": "a comment"},
+ )
+
+ @requirements.comment_reflection
+ @util.provide_metadata
+ def test_drop_table_comment(self):
+ table = self._simple_fixture()
+ table.create(config.db, checkfirst=False)
+ table.comment = "a comment"
+ config.db.execute(schema.SetTableComment(table))
+ config.db.execute(schema.DropTableComment(table))
+ eq_(inspect(config.db).get_table_comment("test_table"), {"text": None})
+
__all__ = ("TableDDLTest",)