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

how do I define a "label" field in sql_table object? #1419

Closed
imding opened this issue Jun 18, 2023 · 3 comments
Closed

how do I define a "label" field in sql_table object? #1419

imding opened this issue Jun 18, 2023 · 3 comments

Comments

@imding
Copy link

imding commented Jun 18, 2023

Hi, I'm trying to define the following SQL table:

TableName: {
    shape: sql_table
    id: String {constraint: primary_key}
    label: String
}

where label is an actual column, the D2 compiler is interpreting it as the label for the table in the graphical output:
image

@janydoe
Copy link
Contributor

janydoe commented Jun 21, 2023

it because label is reserved word.

You are trying to change the label for the current container. It is similar to the following:

TableName: String {
    shape: sql_table
    id: String {constraint: primary_key}
}

Instead you should change key for the "column" shape.

I use "string-literal-hack":

TableName: {
    shape: sql_table
    id: String {constraint: primary_key}
    "label ": String
}

Also, you can use "escape-hack" 😄

TableName: {
    shape: sql_table
    id: String {constraint: primary_key}
    \ label: String
}

Rendered

image

@alixander
Copy link
Collaborator

yeah sorry quotes should bypass the reserved nature of the keyword. it's an open wip

@imding
Copy link
Author

imding commented Jun 28, 2023

thanks this is a good workaround!!

@imding imding closed this as completed Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

3 participants