R0tenur / visualization

MIT License
169 stars 25 forks source link

Tables with a field with a name where there's a / in, will fail in mermaid #130

Closed FoxyHunter7 closed 9 months ago

FoxyHunter7 commented 9 months ago

In T-SQL it is possible to make a column with a name that has a / in it. This / will will mess up the mermaid syntax, and generating a preview will fail. See images below: image image

This is an example with a / however, by using square brackets, it is possible to use many special characters as column name in T-SQL.

Expected Behavior

In this case it is expected that this fails, for the reason above, however the desired behaviour would be that it can still show the schema.

Current Behavior

As described above, the mermaid syntax is invalid and schema visualisation fails. image

Possible Solution

Make the parser aware of these special symbols so that it can either remove or deal with them properly in the mermaid syntax. in the screenshot of the MD provided above, removing the / solves the issue and mermaid shows schema properly.

Steps to Reproduce

  1. create a table
  2. add a column with a name that has a special character in it (in this case a /)
  3. generate schema of it
  4. see that it doesn't work
R0tenur commented 9 months ago

Will investigate!

R0tenur commented 9 months ago

Mermaid don't support this, I have made an workaround and replaced the / with _ in the new version: https://github.com/R0tenur/visualization/releases/tag/v0.9.2

FoxyHunter7 commented 9 months ago

this indeed fixes when there's a /. Hover, unfortunately there are a lot more things that are allowed in sqlserver that can break mermaid syntax, such as %, etc... Anything that can be regarded as markdown syntax can break it.

I have done some research myself, and it seems like it is impossible to do special character escapement in that place in mermaid. image

so perhaps it would be possible to not only replace / but also some other, or at least something that can detect special characters, and warn the user that special characters were used in the column name(s) and that it may or may not break stuff.

Never the less, thanks for the quick reaction.

R0tenur commented 9 months ago

Yes I decided to do a quick fix for this and another persons issue with columns starting with numbers. Next step would be to capture more and produce a warning. And last, might try to make it possoble to revolve https://github.com/mermaid-js/mermaid/issues/1546 on the mermaid side