JSqlParser icon indicating copy to clipboard operation
JSqlParser copied to clipboard

subtract int from date doesn't work

Open sixinli opened this issue 2 years ago • 2 comments

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. SELECT true WHERE '2001-09-28' < date '2001-09-28' + integer '7'
  2. Parsing this SQL using JSqlParser with this statements
  3. Exception
org.junit.ComparisonFailure: Expected query to parse but it failed to parse (error: Encountered unexpected token: "\'7\'" <S_CHAR_LITERAL>
    at line 1, column 62.

Expected behavior query to parse according to https://www.postgresql.org/docs/9.1/functions-datetime.html, but it doesn't alternative SELECT true WHERE '2001-09-28' < date '2001-09-28' + interval '7 days' works but it's not of type date anymore

System

  • Postgres
  • Java 11
  • JSqlParser 4.2

sixinli avatar Oct 26 '21 19:10 sixinli

I can only repeat what I have explained before: JSQLParser does not support implicit casting like integer '7'. Explicit casting Cast('7' AS integer) or '7'::integer will work.

manticore-projects avatar Oct 26 '21 19:10 manticore-projects

Duplicate of #1344

manticore-projects avatar Oct 26 '21 19:10 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