JSqlParser icon indicating copy to clipboard operation
JSqlParser copied to clipboard

Unable to wrap expression in brackets

Open SerialVelocity opened this issue 5 years ago • 2 comments

Bug

The following (Postgres?) queries cannot be parsed:

SELECT (integer '1');
-- Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "\'1\'" <S_CHAR_LITERAL>
--     at line 1, column 17.
SELECT * FROM tmp2 WHERE col between (date '01-01-2010') and (date '02-01-2010' + integer '1');
-- Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "between" "BETWEEN"
--     at line 1, column 30.
SELECT * FROM tmp2 WHERE col between (select (date '01-01-2010')) and (select (date '02-01-2010' + integer '1'));
-- Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "between" "BETWEEN"
--     at line 1, column 30.

It looks like all the queries are because of the same bug but I included all of them just in case.

System

  • Java Version 11
  • JSqlParser version 3.1

SerialVelocity avatar Jan 22 '20 17:01 SerialVelocity

This looks strange. Brackets should it be the problem my first guess is this integer 1 thing.

wumpz avatar Jan 22 '20 23:01 wumpz

Postgres implicit casts are not supported.

Explicit cast will work:

SELECT ( '1'::integer )
;


SELECT CAST('1' AS integer)
;

Duplicate of #1344

manticore-projects avatar Sep 25 '21 09:09 manticore-projects

I am closing this since it is not support and won't be supported (unless any genius provided a PR).

manticore-projects avatar Sep 06 '23 07:09 manticore-projects