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] # marking temporary table instead starts a comment #4130

Open
aidas-atu opened this issue Jan 6, 2025 · 5 comments
Open

[SQL] # marking temporary table instead starts a comment #4130

aidas-atu opened this issue Jan 6, 2025 · 5 comments

Comments

@aidas-atu
Copy link

aidas-atu commented Jan 6, 2025

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

@BenjaminSchaaf BenjaminSchaaf transferred this issue from sublimehq/sublime_text Jan 6, 2025
@deathaxe
Copy link
Collaborator

deathaxe commented Jan 6, 2025

Which server?

Current SQL syntax primarily supports MySQL, which says the following about comments and identifiers:

According to those specs, # introduces a line comment and unquoted identifiers may consist of ASCII only.

Same is true for MariaDB

@michaelblyons
Copy link
Collaborator

Looks like MS SQL Server. Maybe explain DefaultSyntaxChooser?

@deathaxe
Copy link
Collaborator

deathaxe commented Jan 6, 2025

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.

@michaelblyons michaelblyons changed the title SQL characters after '#' is highligted as comment [SQL] # marking temporary table instead starts a comment Jan 7, 2025
@michaelblyons
Copy link
Collaborator

@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.

@deathaxe
Copy link
Collaborator

deathaxe commented Jan 7, 2025

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".

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

No branches or pull requests

3 participants