Skip to content

Crashes if columns have defined enums #13

Description

@richardmaw-codethink

Describe the bug

mkdocs-dbml raises an exception pointing to

if len(type_text) > 15:
because the column type is Enum which doesn't implement len.

To reproduce

  1. Add plugin to mkdocs.yml: ...
  2. Put DBML containing enums in a page
  3. Run mkdocs serve
  4. See error / wrong diagram

Expected behavior
DBML tables rendered.

Environment

  • OS: Linux, but should happen on any.
  • Python: 3.13, but should happen on any
  • MkDocs: 1.6.1
  • mkdocs-dbml-plugin: Latest, but appears to be present as far back as 1.0.0

Additional context

The type of columns is defined to be str | Enum at https://github.com/Vanderhoof/PyDBML/blob/04d19974193a9bb173436dab53b94ecc2919fd58/pydbml/_classes/column.py#L25

It it converted from string form to Enum in https://github.com/Vanderhoof/PyDBML/blob/04d19974193a9bb173436dab53b94ecc2919fd58/pydbml/parser/blueprints.py#L146

Enums implement str (https://github.com/Vanderhoof/PyDBML/blob/04d19974193a9bb173436dab53b94ecc2919fd58/pydbml/_classes/enum.py#L81) and str.str reflexively returns itself so type_text = str(column.type) should fix that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions