JSqlParser icon indicating copy to clipboard operation
JSqlParser copied to clipboard

parse args in case when error

Open wolfjiang opened this issue 3 years ago • 5 comments
trafficstars

I have a stamemnt than run ok in postgresql : select * from customer m where id=case when id > max(id, :maxValue) then 1 else 2 end, max is customized defined function, but sql parser error: `10:58:25.213 [main] ERROR com.q7link.framework.sql.utils.SqlParser - parse sql error : select * from customer m where id=case when id > max(id, :maxValue) then 1 else 2 end

java.lang.RuntimeException: net.sf.jsqlparser.JSQLParserException: Encountered unexpected token: "(" "(" at line 1, column 53.`

change arg maxValue to maxValue, it work fine. does maxValue is keyword not as argument name? change arg maxValue to max, eg. "select * from customer m where id=case when id > max(id, :max) then 1 else 2 end", it work without error.

wolfjiang avatar Jul 12 '22 02:07 wolfjiang

also, "UR" | "RS" | "RR" | "CS" cannot as table alias, too.

it all work fine at version 1.4, now update to 4.4, many statement error occor.:(

wolfjiang avatar Jul 12 '22 03:07 wolfjiang

On Mon, 2022-07-11 at 20:59 -0700, wolfjiang wrote:

"UR" | "RS" | "RR" | "CS"

Those keywords have been allowed again in 4.5-Snapshot. Please download the latest Snapshot, there is a Maven Artifact available.

Bets regards Andreas

manticore-projects avatar Jul 12 '22 04:07 manticore-projects

On Mon, 2022-07-11 at 20:59 -0700, wolfjiang wrote: "UR" | "RS" | "RR" | "CS" Those keywords have been allowed again in 4.5-Snapshot. Please download the latest Snapshot, there is a Maven Artifact available. Bets regards Andreas

OK, thanks

wolfjiang avatar Jul 12 '22 04:07 wolfjiang

But, The maxValue not fix

wolfjiang avatar Aug 02 '22 03:08 wolfjiang

But, The maxValue not fix

Greetings! Good catch:

-- works
select fun( id, ?);

-- works
select fun( id, :param);

-- fails since "maxValue" is not an allowed token?
select fun( id, :maxValue);

manticore-projects avatar Aug 02 '22 03:08 manticore-projects

Works with JSQLParser 4.6. http://jsqlformatter.manticore-projects.com/jsqlformatter/demo.html?args=-c%20LTAEHcHsCcGsGcBQBlAogGVQYQCqgGICuAdgBSgCWAJgDSgD8oAlIgNyIcgQwIobZ4iZSrVAAuAA4BDaFIC2zNh0RcAZlIoAbeKHgViAYwCmoAERypADwBqUzYSOnKO4pAAuoKcU+bNkcEZUoG6QsEbE9HyYuAQk5NR0YhY2dg6KrEA

manticore-projects avatar Nov 12 '22 06:11 manticore-projects