-
-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use 'UK' and column comments #7
Conversation
Mermaid supports a key type of 'UK' for unique key, better to use that instead of adding a comment. Also, if the SQLAlchemy column has a comment assigned, we should add that to the Mermaid comment.
Can you fix the errors from testing? You should be able to pull down the branch and run |
Thanks for the |
I can update the test suite as well, brb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good but I put a few comments in for changes. Thanks for putting this together!
paracelsus/transformers/mermaid.py
Outdated
@@ -29,15 +30,16 @@ def _column(self, column: Column) -> str: | |||
column_str += " PK" | |||
elif len(column.foreign_keys) > 0: | |||
column_str += " FK" | |||
options.append(f"Foreign key references {column.table.name}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make this a separate pull request? I'm not sure I want this comment in there, especially when we have the relationships drawn out already with the diagram itself.
paracelsus/transformers/mermaid.py
Outdated
|
||
options = [] | ||
if column.comment: | ||
options.append(f"{column.comment}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since column.comment is a string the f string and quotes are redundant-
In other words both of these lines are the same, so it should use the succinct one:
options.append(column.comment)
options.append(f"{column.comment}")
tests/transformers/test_mermaid.py
Outdated
@@ -4,6 +4,7 @@ | |||
def test_mermaid(metaclass): | |||
mermaid = Mermaid(metaclass=metaclass) | |||
graph_string = str(mermaid) | |||
print(graph_string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You left a debugging statement here.
Mermaid supports a key type of 'UK' for unique key, better to use that instead of adding a comment. Also, if the SQLAlchemy column has a comment assigned, we should add that to the Mermaid comment.
Here's the output for a table has has both a unique key and a comment in SQLAlchemy after the changes in this pull request: