Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upTRUE and FALSE in WHERE clause are parsed as columns #926
Comments
|
That is true. Because JSqlParser is not only a PostgreSQL parser and other DBMS do not have this true / false keywords, this is by design. How should we differ between TRUE as a value and TRUE as a column name? |
Oh! I didn't realise that. I thought most databases have
Just assume we always interpret |
I think if a query is valid in another database, it should be parsed by JSQLParser (without having to add extra quotes, etc). @wumpz I think we had a small discussion on the Postgres array syntax issue a while ago that it might be a good idea to have a flag indicating what kind of database syntax is being parsed. It would help here as well because the parser could interpret |
|
I don't see the benefit here. The user just need to check the column names. The same would apply to some rownum, sysdate, now functions that could be used without brackets. So it makes things more complicated. Do you suggest a flag for all of these? |
|
The benefit is that users don't need to special case things like this, it gets parsed according to the dialect. I would expect a flag to cover all of these (unrelated thing: rownum is a pseudo-column afaik so maybe it would still be a column?). For example, if you are creating a visitor that visits all functions, you need to remember to visit column names too and make sure "sysdate", etc aren't being used. If values are parsed as a function by the dialect, it would be good for JSQLParser to recognise them as functions too. |
|
Making JsqlParser accept the SQL dialect of the query being parsed would be a good feature to have. It would help with flagging usages such as the usage of For fixing this issue, I think a short-term solution would be to just always interpret |
Describe the bug
Boolean values in WHERE clause are identified as columns rather than being identified as primitive values like numbers.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Prints
falseastruein theWHEREclause is not supposed to be considered as a column name.Actual behavior
Prints
true.System