Sublime Forum

SQL syntax highlighting for /' in string

#1

I am seeing an issue where I am putting a Windows path in a single quote string and because it ends with a backslash, Sublime Text thinks I want to escape that closing single quote:

–> ELSE ‘C:\AltiumLibraries\Footprints**’** + Replace(mp.footprint_ref,’.’,’_’) + ‘.PcbLib’

The problem is, this then screws up the syntax highlighting for the rest of the file. I have searched and it appears that the SQL standard for escaping a single quote is doing a double single quote (’’) and not backslash quote (’). From what I have read, MySQL does not follow the standard here; I am using SQL Server.

Does anyone know where in the SQL definition file I can change this and what I would change? I might just copy the original and then make a version for SQL Server. Would I change the file in the install directory or my user specific Application Data directory? Also, do I change the Prestine Packages file (I assume not) or the files just in Packages?

Thanks for any help or pointers.

H

0 Likes

SQL syntax highlight for string ending in backslash
#2

As a work around, I am current using this:

–> ELSE ‘C:\AltiumLibraries\Footprints’ + CHAR(92) + Replace(mp.footprint_ref,’.’,’_’) + ‘.PcbLib’

0 Likes

#3

Yeah, from what I have read, MySQL operates differently than many others. Don’t quote me on it, but what I have read seems to indicate that ‘’ is the SQL standard vs. ', and MySQL goes its own way here. Of course, MySQL is probably used quite a bit by Sublime Text users, so I get the need to make it work for that. Your same select in SQL Server (using single quotes vs. double quotes, as double quotes are reserved for column names) gives me: C:\mofo\

So yeah, there is a difference. No big deal I suppose; I created a work around. But thought it was worth mentioning what I found.

0 Likes

#4

I build my own SQL tmLanguage file for ST1 as I have to program in PL/SQL from Oracle. It now supports the requirements of my company.

I did it more verbose but simpler than the given SQl.tmLanguage file. It is fast enough on my 7 year old machine.

      <key>strings</key>
      <dict>
        <key>patterns</key>
        <array>
          <dict>
            <key>name</key>
            <string>string.quoted.single.plsql</string>
            <key>begin</key>
            <string>'</string>
            <key>end</key>
            <string>'</string>
          </dict>
          <dict>
            <key>name</key>
            <string>string.quoted.double.plsql</string>
            <key>begin</key>
            <string>"</string>
            <key>end</key>
            <string>"</string>
          </dict>
          <dict>
            <key>name</key>
            <string>string.quoted.other.single.plsql</string>
            <key>begin</key>
            <string>(?i)N'</string>
            <key>end</key>
            <string>'</string>
          </dict>
          <dict>
            <key>name</key>
            <string>string.quoted.other.double.plsql</string>
            <key>begin</key>
            <string>(?i)N"</string>
            <key>end</key>
            <string>"</string>
          </dict>
        </array>
      </dict>
0 Likes

#5

This is a bit off topic, but there are some existing resources available for Oracle PL SQL (including syntax highlighting) here: http://code.google.com/p/oracle-textmate-bundle/.

I personally only use the syntax highlighting (http://oracle-textmate-bundle.googlecode.com/svn/trunk/Oracle.tmbundle/Syntaxes/PL:SQL%20%28Oracle%29.tmLanguage), but the other resources might also be useful.

0 Likes

Disable backslash as escape
#6

It seems issue is still actual, this incorrectly highlighted:

UPDATE [results] SET [name]=REPLACE([name], ‘\\’, ‘\’)

0 Likes

#7

Yes, this is well known

0 Likes