k1LoW / tbls

tbls is a CI-Friendly tool for document a database, written in Go.
MIT License
3.34k stars 164 forks source link

Parse error when generating Mermaid ER diagram due to double quotes in entity attribute comments #503

Closed kaitosawada closed 11 months ago

kaitosawada commented 11 months ago

What happened

While generating an ER diagram using Mermaid with tbls, I encountered a parse error. The issue arises when an entity's attribute comment contains double quotes ("), which are allowed in MySQL comments.

What you expected to happened

Ideally, tbls should escape double quotes in DB comments, allowing Mermaid to correctly display them. According to Mermaid's documentation (https://mermaid.js.org/syntax/flowchart.html#entity-codes-to-escape-characters) and this GitHub issue (https://github.com/mermaid-js/mermaid/issues/170), HTML entities can be used to escape characters such as double quotes in Mermaid.

In light of a recent change in tbls that no longer requires HTML encoding (https://github.com/k1LoW/tbls/issues/449), I suggest that tbls should, at minimum, implement escape handling for double quotes in attribute comments. While I considered the possibility of needing to escape characters other than double quotes or in contexts other than attribute comments, I believe that no additional escapes are necessary beyond this.

What stack trace or error message from tbls did you see?

This is not an error caused by tbls, but an error that occurs during parsing in Mermaid. Expecting 'ATTRIBUTE_WORD', got 'COMMENT'

Environment

tbls version: 1.68.1

k1LoW commented 11 months ago

Hi @kaitosawada. Thank you for your contribution!!

The fixed version was released as v1.68.2.

Please check it out at hand.

kaitosawada commented 11 months ago

Hi @k1LoW. Thank you for the quick review, merge, and release! I've checked version v1.68.2 and can confirm the issue is resolved.