Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

9
  • Highlight.js "SQL" language is intended to be very "baseline". It's not going to handle every possible SQL variant well. Currently it includes too much (and on the list to be scaled back)... if someone wants "better/proper" MS SQL support then the correct solution is for someone to provide a 3rd party grammar module for MS SQL variant. Currently we already have PostgreSQL (core) and Transact-SQL (3rd party) grammars in addition to the plain jain "SQL". Commented Oct 7, 2020 at 14:50
  • @JoshGoebel that doesn't explain most of the above. Yes the brackets ([]) are T-SQL specific, however, # is a very different story, as only -- and /*...*/ are the ANSI methods for comments. @ is also the common theme for variables. The majority of this is not T-SQL specific. The misinterpretation of # as a comment is especially detrimental in my opinion.
    – Larnu
    Commented Oct 7, 2020 at 14:53
  • Re:Comments. This is because there yet exists no "MySQL" SQL grammar so that support has been squeezed into SQL... MySQL does indeed allow # comments. What needs to happen here is for someone to creates a separate MySQL grammar and then the SQL grammar can be simplified (removing # comments). Does ANSI SQL even have variables? Variables would be something pretty trivial to add to the existing SQL support (since it currently includes too much). I'd be open to a PR against SQL adding variables. Commented Oct 7, 2020 at 15:08
  • According to this answer from 2014, it does (did) not, @JoshGoebel . Though, not all of the languages use @. For example T-SQL (SQL Server), MySQL use @, where asPL\SQL (Oracle) and pgSQL (PostGreSQL) do not. SQLite doesn't actually support Variables at all; by the looks of it. I do admit that all the RDBMS using (vastly) varying implementations of SQL does pose many problem from the perspective of a generic "SQL" language implementation.
    – Larnu
    Commented Oct 7, 2020 at 15:14
  • 1
    I will add variable support to SQL since that will prevent false keywords also. github.com/highlightjs/highlight.js/pull/2740/commits/… Commented Oct 7, 2020 at 17:14
  • 2
    Sadly the SQL grammar improvements didn't make it into 10.3 because it turns out we're going with a complete rewrite of the SQL grammar. The new grammar should hopefully do much better overall on snippets but will drop vendor-specific (non-standard) things like MySQL comments. We could still use any contributors who might want to create (and help maintain) 3rd party modules for MySQL and Oracle to support the nuances of those vendor's SQL grammars. Commented Oct 17, 2020 at 17:48
  • Thanks for the update @JoshGoebel, appreciate it.
    – Larnu
    Commented Oct 17, 2020 at 18:22
  • I'd be happy to help out with Oracle SQL and PL/SQL, if Oracle Corp can't spare anyone :) Commented Nov 2, 2020 at 23:13
  • 1
    SQL improvements finally landed in 10.5 for a holiday release! SE just updated to 10.4.1 so I'm not sure when the next update will be. CC @BenKelly Commented Dec 23, 2020 at 21:05