Skip to content

Improve TableGroup Rendering for Special Characters in Names #46

@ryanproback

Description

@ryanproback

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions