You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by "Andrus Adamchik (JIRA)" <ji...@apache.org> on 2014/12/09 07:40:12 UTC
[jira] [Updated] (CAY-1978) ESCAPE clause should be included in
LIKE parenthesis
[ https://issues.apache.org/jira/browse/CAY-1978?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andrus Adamchik updated CAY-1978:
---------------------------------
Environment: Cayenne ObjectStyle build: v.4.0.M2.1ab1caa
> ESCAPE clause should be included in LIKE parenthesis
> ----------------------------------------------------
>
> Key: CAY-1978
> URL: https://issues.apache.org/jira/browse/CAY-1978
> Project: Cayenne
> Issue Type: Bug
> Affects Versions: 3.2.M1
> Environment: Cayenne ObjectStyle build: v.4.0.M2.1ab1caa
> Reporter: Andrus Adamchik
> Assignee: Andrus Adamchik
> Fix For: 4.0.M2
>
>
> This may not be a new bug , but it started happening to me with the recent upgrades of Cayenne 4.0 that features more consistent escaping of the LIKE special chars. If LIKE ("likeIgnoreCase" actually, but I think LIKE works similarly) is combined with another qualifier clause, Cayenne wraps it in parenthesis, leaving ESCAPE clause out of them:
> SELECT t0.* FROM mytable t0 WHERE (t0.COLUMN1 = ?) AND (UPPER(t0.COLUMN2) LIKE UPPER(?)) ESCAPE '!'
> [bind: 1->COLUMN1:68, 2->COLUMN2:'%test!_test%']
> This results in an exception on MySQL. Will likely fail on other DBs as well. Will need to translate ESCAPE properly.
> com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException
> You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ESCAPE '!'' at line 1
> SQLState
> 42000
> errorCode
> 1064
> Filter stack frames Stack trace
> java.lang.reflect.Constructor.newInstance(Constructor.java:526)
> com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
> com.mysql.jdbc.Util.getInstance(Util.java:386)
> com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
> com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4187)
> com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4119)
> com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2570)
> com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2731)
> com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2815)
> com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
> com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2322)
> java.lang.reflect.Method.invoke(Method.java:606)
> org.apache.tomcat.jdbc.pool.interceptor.AbstractQueryReport$StatementProxy.invoke(AbstractQueryReport.java:235)
> com.sun.proxy.$Proxy53.executeQuery(Unknown Source)
> org.apache.cayenne.access.jdbc.SelectAction.performAction(SelectAction.java:79)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)