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

Syntax highlighting breaks when using $ in VALUES #237

Open
happenslol opened this issue Jan 15, 2024 · 4 comments
Open

Syntax highlighting breaks when using $ in VALUES #237

happenslol opened this issue Jan 15, 2024 · 4 comments

Comments

@happenslol
Copy link

I'm using sqlc where multiple queries are written in a single sql file, from which code is then generated. Arguments are written as $1, $2 and so on. The dollar signs seem to break syntax highlighting.

The following example shows the bug:

-- name: CreateUser :one
INSERT INTO users (id, name)
VALUES ($1, $2);
RETURNING *;

-- name: CreatePost :one
INSERT INTO posts (id, content)
VALUES ($1, $2)
RETURNING *;

This results in the following:
image

Even with a single function, the RETURNING line breaks:

-- name: CreateUser :one
INSERT INTO users (id, name)
VALUES ($1, $2);
RETURNING *;

image

@matthias-Q
Copy link
Collaborator

matthias-Q commented Jan 15, 2024

Thanks for reporting. I think this has to do with the dollar quoting that has been introduced a couple of weeks ago. I will try to take a closer look.

Btw.: your second example seems to have an additional ; in the second to last line. That might be one issue.

@happenslol
Copy link
Author

Btw.: your second example seems to have an additional ; in the second to last line. That might be one issue.

Ah, totally missed that. Disregard that one then, the highlighting works correctly there. The first case however still breaks:

image

@antoineB
Copy link
Contributor

https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-DOLLAR-QUOTING
The tag, if any, of a dollar-quoted string follows the same rules as an unquoted identifier

https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
SQL identifiers and key words must begin with a letter (a-z, but also letters with diacritical marks and non-Latin letters) or an underscore (_). Subsequent characters in an identifier or key word can be letters, underscores, digits (0-9), or dollar signs ($).

@eklmv
Copy link
Contributor

eklmv commented Mar 13, 2024

You need to check if you not using too old version of a parser, I made fix exactly for that problem: #235.
That how it looks for me:
image
With removed ;:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants