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 Syntax Highlighter Issue with CASE statement #12610

Closed
pamanes opened this issue Dec 6, 2022 · 5 comments
Closed

SQL Syntax Highlighter Issue with CASE statement #12610

pamanes opened this issue Dec 6, 2022 · 5 comments

Comments

@pamanes
Copy link

pamanes commented Dec 6, 2022

Description of the Issue

SQL file syntax highlighter fails when a case is involved in a specific way

Steps to Reproduce the Issue

  1. Create new File
  2. Paste the following SQL code:
    UPDATE U SET Title = xt.Title OUTPUT case when (inserted.nt_account is not null and charindex('\', inserted.nt_account) > 0) then substring(inserted.nt_account, 1, charindex('\', inserted.nt_account) - 1) else null end domain INTO dbo.TABLE FROM dbo.TABLE2 xt
  3. Save as SQL file type

Expected Behavior

Code after chardindex should not be gray as it's not comments

Actual Behavior

You will notice the code after charindex is GRAY as if they were comments but they are not

image

@rdipardo
Copy link
Contributor

rdipardo commented Dec 7, 2022

N++'s SQL highlighting module was designed for the Oracle PL/SQL dialect, so it's not entirely suitable for Microsoft's Transact-SQL, which I assume you're writing from the "dbo" name qualifier.

Many past users have bumped into this limitation without realizing it, e.g.:

The Lexilla library already used by N++ does have a dedicated T-SQL module, but somebody needs to make a feature request for it to be implemented.

By comparison, here's how SciTE styles your T-SQL query, after enabling the MS SQL module:

Screenshot 2022-12-06 212010

@rdipardo
Copy link
Contributor

rdipardo commented Dec 7, 2022

P.S.
In the meantime, there's a (rather dated) UDL for MS SQL Server 2008 that might be more suitable: https://github.com/notepad-plus-plus/userDefinedLanguages/blob/master/UDLs/T-SQL-MSServer2008r2_bySergeyIvanov.xml

@rdipardo
Copy link
Contributor

rdipardo commented Dec 7, 2022

P.P.S.
I forgot to mention there's a simple, immediate solution to the reported issue:

  1. Settings
  2. Preferences
  3. Language
  4. Uncheck the "Treat backslash as escape character for SQL" option

ignore_bkslash_esc

The extra stuff above is still relevant, but probably more useful as an independent issue.

@pamanes, feel free to close this ticket if the workaround does the trick.

@ArkadiuszMichalski
Copy link
Contributor

Switch option as suggested above.

@pamanes
Copy link
Author

pamanes commented Dec 14, 2022

thanks! that workaround works really well

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.

4 participants