Uploaded image for project: 'Cayenne'
  1. Cayenne
  2. CAY-1978

ESCAPE clause should be included in LIKE parenthesis

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.2.M1, 3.1
    • 4.0.M2, 3.1.1
    • None
    • None
    • Cayenne ObjectStyle build: v.4.0.M2.1ab1caa

    Description

      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)

      Attachments

        Activity

          People

            andrus Andrus Adamchik
            andrus Andrus Adamchik
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: