geshi-1.0 icon indicating copy to clipboard operation
geshi-1.0 copied to clipboard

SQL highlighting broken when string contains square brackets

Open rgpublic opened this issue 7 years ago • 5 comments

When trying to highlight this as SQL:

'['+ABC+']'

I get wrong results.

rgpublic avatar Nov 29 '17 10:11 rgpublic

Which SQL standard is this based on? What special syntax rule does it use?

BenBE avatar Mar 08 '20 22:03 BenBE

https://www.w3schools.com/sql/func_sqlserver_concat_with_plus.asp https://docs.microsoft.com/de-de/sql/t-sql/language-elements/string-concatenation-transact-sql?view=sql-server-ver15

Microsoft SQL-Server, TSQL, Azure DataWarehouse, ...

rgpublic avatar Mar 09 '20 15:03 rgpublic

Can you provide a full example where it doesn't work? @rgpublic SELECT * FROM `CONFINE` WHERE `PRI` = $1 GROUP BY '[' + HEX + ']' properly defines & marks the brackets as a string in my version.

Streusel avatar Mar 31 '20 10:03 Streusel

Does ist also work for you with '['+ABC+']' @Streusel ? Yes, I know it's not a full example. But: I came here because the GeSHi highlighter is used in Drupal's "Geshi Filter for syntax highlighting" module:

https://www.drupal.org/project/geshifilter

This module is used on a site we're taking care of for a blog about programming issues to format code excerpts. Sometimes, there's only a short code excerpt discussed. It's not always a full executable MySQL statement. But shouldn't the above thing be formatted right anyway? It works if there is not a square bracket within the quotes. Doesn't make that much sense to me...

rgpublic avatar Mar 31 '20 11:03 rgpublic

Just using '['+ABC+']' works fine as well. I'm personally using version 1.0.8.9 of the sql file. Screen Shot 2020-03-31 at 3 40 42 PM

Streusel avatar Mar 31 '20 13:03 Streusel