simple-sql-parser icon indicating copy to clipboard operation
simple-sql-parser copied to clipboard

reservedWord implementation prevents parsing of CURRENT_TIMESTAMP

Open agentm opened this issue 6 years ago • 2 comments

I don't fully understand how the reserved word blacklist is supposed to work, but the implementation seems to block basic usage of the reserved words. For example, this is ANSI SQL:

SELECT CURRENT_TIMESTAMP;

With or without parentheses, this fails to parse. My quick workaround is to remove "current_timestamp" from the reserved word list, but that probably has other implications.

agentm avatar Aug 29 '19 22:08 agentm

Supporting this has never been considered, it's just an oversight. I think the right approach is a whitelist like with the function names. Usually, removing things like this from the keyword list has little downside. It's removing things like 'from' and 'where' from the keyword list that can lead to really bad error messages when you make a syntax mistake.

JakeWheat avatar Aug 31 '19 07:08 JakeWheat

You can now override these keyword lists in 0.6.0, in this case you could add 'CURRENT_TIMESTAMP' to the list of identifier keywords in the dialect. I hope to get round to fixing the ansi sql dialect properly.

JakeWheat avatar Sep 21 '19 08:09 JakeWheat