diff options
author | mike bayer <mike_mp@zzzcomputing.com> | 2017-03-17 14:16:27 -0400 |
---|---|---|
committer | Gerrit Code Review <gerrit@awstats.zzzcomputing.com> | 2017-03-17 14:16:27 -0400 |
commit | d96fc5d02a921820aa5973daf66445c880ca6cd4 (patch) | |
tree | a7b3a47cca6e9a5af48dda6b3d92e3ba3f0b2418 /lib/sqlalchemy/sql/ddl.py | |
parent | 9974e9a46bdf6c570c650aa911b76c2dcfd9327b (diff) | |
parent | fadb8d61babb76ef7bdbc98279096a8900c7328d (diff) | |
download | sqlalchemy-d96fc5d02a921820aa5973daf66445c880ca6cd4.tar.gz |
Merge "Implement comments for tables, columns"
Diffstat (limited to 'lib/sqlalchemy/sql/ddl.py')
-rw-r--r-- | lib/sqlalchemy/sql/ddl.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/sqlalchemy/sql/ddl.py b/lib/sqlalchemy/sql/ddl.py index 5463afe99..74c424bff 100644 --- a/lib/sqlalchemy/sql/ddl.py +++ b/lib/sqlalchemy/sql/ddl.py @@ -661,6 +661,30 @@ class DropConstraint(_CreateDropBase): self._create_rule_disable) +class SetTableComment(_CreateDropBase): + """Represent a COMMENT ON TABLE IS statement.""" + + __visit_name__ = "set_table_comment" + + +class DropTableComment(_CreateDropBase): + """Represent a COMMENT ON TABLE IS NULL statement.""" + + __visit_name__ = "drop_table_comment" + + +class SetColumnComment(_CreateDropBase): + """Represent a COMMENT ON COLUMN IS statement.""" + + __visit_name__ = "set_column_comment" + + +class DropColumnComment(_CreateDropBase): + """Represent a COMMENT ON COLUMN IS NULL statement.""" + + __visit_name__ = "drop_column_comment" + + class DDLBase(SchemaVisitor): def __init__(self, connection): self.connection = connection @@ -771,6 +795,14 @@ class SchemaGenerator(DDLBase): for index in table.indexes: self.traverse_single(index) + if self.dialect.supports_comments and not self.dialect.inline_comments: + if table.comment is not None: + self.connection.execute(SetTableComment(table)) + + for column in table.columns: + if column.comment is not None: + self.connection.execute(SetColumnComment(column)) + table.dispatch.after_create( table, self.connection, checkfirst=self.checkfirst, |