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

compiler: escape reserved keywords #477

Open
alixander opened this issue Dec 20, 2022 · 5 comments · May be fixed by #800
Open

compiler: escape reserved keywords #477

alixander opened this issue Dec 20, 2022 · 5 comments · May be fixed by #800

Comments

@alixander
Copy link
Collaborator

E.g. width and height should be usable as sql table column keys.

https://play.d2lang.com/?script=AvnbSiE4sypVoZpLQQHsaiuF4sKc-JLEpJxULgUFJbA6JSuFvNLcpNQikAgkoBBCtVyAAAAA__8%3D

@alixander
Copy link
Collaborator Author

@alixander
Copy link
Collaborator Author

@nhooyr any ideas on how best to do this? Just prefix a backslash? e.g. \shape: int

@alixander
Copy link
Collaborator Author

this isn't an issue normally, because you can just relabel things, e.g.

x: { s: "shape" }

but for SQL tables this doesn't work

@alixander
Copy link
Collaborator Author

for now i should just make sure label works for sql table columns

x: {
  shape: sql_table
  s: int { label: shape }
}

@nhooyr
Copy link
Contributor

nhooyr commented Feb 12, 2023

Ooo I see, we should change the compiler to ensure that any reserved key is unquoted and without any backslashes.

Also need autofmt to preserve backslashes which I don't remember if it does right now. I know it doesn't preserve line continuations still.

@alixander alixander linked a pull request Feb 12, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

2 participants