Skip to content
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

Improve TableGroup Rendering for Special Characters in Names #46

Open
ryanproback opened this issue Nov 26, 2024 · 2 comments
Open

Improve TableGroup Rendering for Special Characters in Names #46

ryanproback opened this issue Nov 26, 2024 · 2 comments

Comments

@ryanproback
Copy link

The current implementation of TableGroup rendering in pydbml does not wrap the TableGroup name in double quotes. This can lead to issues when using special characters like dashes (-) in TableGroup names.

For example:

TableGroup Unanimate {
    "books"
    "countries"
}

TableGroup mygroup-1 { // dbdocs validate error!
    "books"
    "countries"
}

If the TableGroup name contains a dash, it may result in syntax errors or unexpected behavior.

Proposed Improvement:

Update the TableGroup rendering logic to wrap TableGroup names in double quotes. This ensures compatibility with special characters and aligns with DBML’s syntax flexibility.

Proposed change in table_group.py:

result += f'TableGroup "{model.name}" {{\n'

With this change, a TableGroup with a name like mygroup-1 would be rendered as:

TableGroup "mygroup-1" {
    "products"
    "orders"
}

Benefits:

  • Enables the use of special characters like -, etc., in TableGroup names.
  • Improves compatibility and usability when naming TableGroups.
  • Avoids potential DBML syntax issues caused by unquoted names.

Additional Note:

If the maintainers agree with this improvement, I am happy to contribute a pull request with the necessary code changes and test updates.

Let me know your thoughts!

@Vanderhoof
Copy link
Owner

Makes total sense to me. I'll be implementing that in the near future and release along with your fix in the next version 🙌

@Vanderhoof
Copy link
Owner

Oh, and and if you wish, feel free to create a pull requests with this change, as you suggested. I still have to update the syntax compliance to the latest version anyway : }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants