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

Single-quoted variables not working for SQL highlighting #1509

Closed
H3dg3 opened this issue Aug 1, 2018 · 7 comments · Fixed by #1510
Closed

Single-quoted variables not working for SQL highlighting #1509

H3dg3 opened this issue Aug 1, 2018 · 7 comments · Fixed by #1510

Comments

@H3dg3
Copy link

H3dg3 commented Aug 1, 2018

According to the examples, the following should work, but it does not
SET @'quoted-variable' = 3;
All other quoted variable examples do work, i.e. the following:

SET @variable = 1;
SET @$_ = 2;
SET @"quoted-variable" = 3;
SET @`quoted-variable` = 3;
@RunDevelopment
Copy link
Member

Cannot reproduce.
image

Are you also using some plugin or do have other code which also produces the error?

@H3dg3
Copy link
Author

H3dg3 commented Aug 1, 2018

I can reproduce it like this:

SET @'quoted-variable' = 3;
SET @'quoted-variable' = 3;

It seems to be a multiline issue. I will try to assemble a minimal example.

@H3dg3
Copy link
Author

H3dg3 commented Aug 1, 2018

Here you go: https://jsfiddle.net/zL9hbdo4/2/
I hope a fiddle is OK.

@RunDevelopment
Copy link
Member

Thank you for providing this example.
I have found the problem and will provide a fix soon.

@RunDevelopment
Copy link
Member

While the simple example of

SET @'quoted-variable' = 3;
SET @'quoted-variable' = 3;

is now working correctly, due to a greedy matching bug (#1492) the other example is still not highlighted correctly.

CREATE USER 'user'@'server-ip' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON scheme.* TO 'user'@'server-ip' WITH GRANT OPTION;

image

@RunDevelopment
Copy link
Member

I used a littly trick to by pass the greedy bug. I won't work 100% of the time but it should solve your issue.

image

@H3dg3
Copy link
Author

H3dg3 commented Aug 1, 2018

I just tested with the last commit on my end and it works like a charm. Hope the fix makes it into the 1.16.0 👍

@H3dg3 H3dg3 closed this as completed Aug 1, 2018
mAAdhaTTah pushed a commit that referenced this issue Aug 23, 2018
Behavior with quoted variables was incorrect for SQL. This fixes that issue
by introducing a new regex for variables and making the current regex greedy.

Fixes #1509.
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

Successfully merging a pull request may close this issue.

2 participants