JSqlParser icon indicating copy to clipboard operation
JSqlParser copied to clipboard

[FEATURE] allow RDBMS specific keywords as columns

Open d2a-raudenaerde opened this issue 1 year ago • 2 comments

Grammar or Syntax Description

  • Postgresql allows some keywords as column names (i.e. start)

SQL Example

  • Simplified Query Example, focusing on the failing feature
    SELECT 'Monday' AS start
    

Currently, I get a parse error.

Was expecting one of:

    "::"
    "^"
    <EOF>
    <ST_SEMICOLON>

I do not really consider this as bug, as I can understand that by default when making a generic sql parser you want to follow the standard keywords strictly. However, Postgres is a bit more lenient: https://www.postgresql.org/docs/current/sql-keywords-appendix.html

It would be nice if this is configurate / a Feature ?

d2a-raudenaerde avatar Aug 28 '24 13:08 d2a-raudenaerde

Greetings!

"START" is a reserved keyword and will need to be quoted.

manticore-projects avatar Aug 28 '24 14:08 manticore-projects

I know :)

The feature request is to allow some keywords to be 'white-listed'. I can't quote all my 10.000+ scripts by hand (I'd need a parser for that to do that effectively...)

Ok. I know, it will be a subset of those scripts, and I can grep 'start' so it will be a lot less but still annoying. Would be nice if Postgres was stricter so the ppl here would not use these keywords unquoted.

d2a-raudenaerde avatar Aug 28 '24 15:08 d2a-raudenaerde

Greetings!

You will have to edit the keyword definitions in the Grammar and change the keyword classification/restriction there. Then run the "Update keywords" task as described here: https://manticore-projects.com/JSQLParser/contribution.html#manage-reserved-keywords and then run the standard test suite. If all tests succeed we can merge your relaxed keywords and your PR will be welcome.

Although "START" is a reserved keyword in SQL:2016 and should be avoided in my opinion.

manticore-projects avatar Aug 30 '24 07:08 manticore-projects

Ah I have to build a custom jar for sql parser then. Makes sense (and I totally agree with sticking to the standard, it is unfortunate that we already have such a large mass of non-standard scripts)

d2a-raudenaerde avatar Aug 30 '24 08:08 d2a-raudenaerde

No custom jar needed. Just send a PR when you have relaxed the keyword definition and we merge it into master.On 30 Aug 2024 09:20, Rob Audenaerde @.***> wrote: Ah I have to build a custom jar for sql parser then. Makes sense (and I totally agree with sticking to the standard, it is unfortunate that we already have such a large mass of non-standard scripts)

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

manticore-projects avatar Aug 30 '24 09:08 manticore-projects

Greetings,

I have tried to allow "START", but the grammar will break and not compile ("unreachable statement"). There is no easy way to fix it, but of course any PRs improving the situation would be welcome.

manticore-projects avatar Sep 14 '24 10:09 manticore-projects