[SQL] `#` marking temporary table instead starts a comment
Description of the bug
Normally temp tables in SQL starts # character, and everything after becomes highligted as a comment.
Steps to reproduce
paste these into sublime when highlighting is set to SQL:
select * from #table where id = 2
select * from table1 where id = 2
1st line after # is highlighted as comment
Expected behavior
# character should not be treated as a start of a commnet.
Actual behavior
# character is treated as a start of a comment.
Sublime Text build number
4189
Operating system & version
Windows 11 pro
Which server?
Current SQL syntax primarily supports MySQL, which says the following about comments and identifiers:
- https://dev.mysql.com/doc/refman/8.0/en/comments.html
- https://dev.mysql.com/doc/refman/8.0/en/identifiers.html
According to those specs, # introduces a line comment and unquoted identifiers may consist of ASCII only.
Same is true for MariaDB
- https://mariadb.com/kb/en/comment-syntax/
- https://mariadb.com/kb/en/identifier-names/
Looks like MS SQL Server. Maybe explain DefaultSyntaxChooser?
Can confirm, T-SQL syntax supports hashed identifiers.
It is however not released with any ST build, so I assume the report targeting old naive implementation.
Anyway, maybe we should considder adding a simplified default syntax chooser so modifying default dialect works out of the box.
@aidas-atu There is a pre-release version of syntax highlighting that fixes your issue. SQL has been broken into multiple flavors that have conflicting syntax specs. In this particular case, I think MySQL wants it to be a comment and MS SQL wants it to be a temp table.
If you want to use this feature before it releases, you can follow the instructions in the ReadMe of this repo, and then use the T-SQL flavor for your standalone SQL files. To get it embedded into strings in other languages, there are some more steps. Reply if those are needed.
Note SQL is extended by and embedded in various syntaxes, thus various packages may need to be overridden to avoid errors with regards to "mismatching syntax versions".
ST4200 is out with rewritten SQL supporting MSSQL / T-SQL.
Default SQL syntax used in embedded strings can be adjusted via DefaultSyntaxChooser until we come op with a bundled plugin providing suitable command for it.