sql-highlight
sql-highlight copied to clipboard
Any non-keyword word is considered as identifier
Describe the bug
insert into "brands" ("name") values ('Aston Martin') returning "id", "name"
In this example returning keyword is not in keywords list and is considered as identifier.
Expected behavior
Any non-keyword should be considered unknown or all keywords should be added to the keywords list.
All keywords can be taken from postgres docs
Screenshots
sql-highlight (please complete the following information):
- Version: 5.0.0-beta.2
This is also an issue for any non-postgres SQL dialect that has more/some other keywords.
Any non-keyword should be considered unknown
If we did that though, then no strings would be marked as identifiers.
or all keywords should be added to the keywords list... All keywords can be taken from postgres docs
I guess that's a better argument, although I cringe to think that in a string like below, "a" and "c" would be marked as keywords rather than identifiers:
select * from tab where a > c
The current architecture (doing everything by regexp) has inherent limitations, so there need to be some compromises. It seems like adding all those strings as keywords might make things worse (overall) rather than better.
PS: I guess what I'm saying is that it's only safe to list reserved keywords in the keywords section (and "returning" is non-reserved).
Hey there. I think to avoid the odd cases such as a > c we'll just keep accepting suggestions for new keywords for the time being. The returning keyword was added in #188 so I'll mark this as closed.