Menu

#1374 add_months in combination with extract loses bracket

current-release
closed-works-for-me
nobody
None
5
2014-10-31
2014-10-31
Pali Haneul
No

I'm using version 2.3.2, the datasource has 'sql.syntax_ora=true'.

When I'm using the query:
"SELECT t FROM Table t WHERE 1=1" I get all rows;
"SELECT t FROM Table t WHERE 1=1 OR ADD_MONTHS(sysdate,1) > sysdate" I get all rows;
"SELECT t FROM Table t WHERE 1=1 OR EXTRACT(month FROM sysdate) > 0" I get all rows;

However, when I make a combination:
"SELECT t FROM Table t WHERE 1=1 OR EXTRACT(month FROM ADD_MONTHS(sysdate,1)) > 0" I get an error: util.JDBCExceptionReporter - unexpected token: )

The recompiled SQL shows a missing part ',1)':
Hibernate: select ... as ... from ... where 1=1 or extract(month FROM ADD_MONTHS(sysdate)>0

I tried wrapping things with additional brackets but havent found a working solution yet. The query does run fine in Oracle.

Discussion

  • Fred Toussi

    Fred Toussi - 2014-10-31

    It seems you are not reporting the actual query. The queries you report working will all fail as TABLE is a reserved word in this context.

    Your query does not make sense, as the OR conditions ensures all the rows of the table are returned anyway.

    The last query works fine in my test when a proper table name and column name is used.

     
  • Fred Toussi

    Fred Toussi - 2014-10-31
    • status: open --> closed-works-for-me
     

Log in to post a comment.