Improve TableGroup Rendering for Special Characters in Names
Opened this issue · 2 comments
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!
Makes total sense to me. I'll be implementing that in the near future and release along with your fix in the next version 🙌
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 : }