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

SQL strings should not require ; as the end delimeter. #6

Closed
denysonique opened this issue Apr 11, 2021 · 1 comment
Closed

SQL strings should not require ; as the end delimeter. #6

denysonique opened this issue Apr 11, 2021 · 1 comment
Labels
wontfix This will not be worked on

Comments

@denysonique
Copy link

denysonique commented Apr 11, 2021

NodeJS libraries allow executing SQL queries by passing a non-delimeted string such as below:

db.query(`SELECT * FROM sometable`)

However the below pattern used for matching requires a semi-colon:

                    "end": "(;)",

I tried adding a leading backtick:

         "begin": "`(SELECT|INSERT|DELETE|UPDATE|DROP|ALTER|CREATE|SET|TRUNCATE|GRANT|REVOKE)\\s",
          "end": "`"

which seems to work, however by adding the backtick I loose the option to precede the query with a newline for formating of longer queries:

db.query(`
   SELECT .....
   WHERE
   INNER JOIN
   INNER JOIN 
   ....
`)

If I try to solve this by only adding a backtick to the "end" value, syntax highlihgting brakes for anything below.

What is the best solution to be able to have all strings beginning with a ` followed by newline + whitespace and then SELECT or other keywoard to be fully highlighted without having to delimit them with a ;

@iuyoy
Copy link
Owner

iuyoy commented Apr 24, 2021

VS Code uses TextMate grammars as the syntax tokenization engine.
In 12.2 Language Rules of the TextMate document language_grammars says that:
image
and in next section, it says
image
So it is impossible to match the multi-line beginning.

What's more, there may be some mis-highlighting if ` is used in SQL, while ; is easily appended to any SQL. They are the reasons why I choose ; as the end expression.

@iuyoy iuyoy added the wontfix This will not be worked on label Oct 25, 2021
@iuyoy iuyoy closed this as completed Oct 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants