diff --git a/paracelsus/transformers/mermaid.py b/paracelsus/transformers/mermaid.py index 14b07cd..6414150 100644 --- a/paracelsus/transformers/mermaid.py +++ b/paracelsus/transformers/mermaid.py @@ -20,6 +20,7 @@ def _table(self, table: Table) -> str: return output def _column(self, column: Column) -> str: + options = [] column_str = f"{column.type} {column.name}" if column.primary_key: @@ -29,15 +30,15 @@ def _column(self, column: Column) -> str: column_str += " PK" elif len(column.foreign_keys) > 0: column_str += " FK" + elif column.unique: + column_str += " UK" - options = [] + if column.comment: + options.append(column.comment) if column.nullable: options.append("nullable") - if column.unique: - options.append("unique") - if column.index: options.append("indexed") diff --git a/tests/conftest.py b/tests/conftest.py index ee125e6..5430302 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -23,7 +23,7 @@ class Post(Base): id = mapped_column(Uuid, primary_key=True, default=uuid4()) author = mapped_column(ForeignKey(User.id), nullable=False) created = mapped_column(DateTime, nullable=False, default=datetime.utcnow()) - live = mapped_column(Boolean, default=False) + live = mapped_column(Boolean, default=False, comment="True if post is published") content = mapped_column(Text, default="") class Comment(Base): diff --git a/tests/transformers/test_mermaid.py b/tests/transformers/test_mermaid.py index 0d4b8da..cd176e1 100644 --- a/tests/transformers/test_mermaid.py +++ b/tests/transformers/test_mermaid.py @@ -15,4 +15,5 @@ def test_mermaid(metaclass): assert "CHAR(32) author FK" in graph_string assert 'CHAR(32) post FK "nullable"' in graph_string + assert 'BOOLEAN live "True if post is published,nullable"' in graph_string assert "DATETIME created" in graph_string