Grails
  1. Grails
  2. GRAILS-8901

updateAll() / deleteAll() fails if criteria contains =~ (ilike) operator

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0.1
    • Fix Version/s: 2.0.2
    • Component/s: Persistence
    • Labels:
    • Environment:
      Ubuntu 11.10 64bit, Java 7 (not relevant for the issue)

      Description

      Create a detached query for a domain class like this

      def criteria = MyDomain.where {
      	myInt == 10
      	myString =~ "myString%"
      }
      

      The query works when using criteria.findAll() but fails when trying to update or delete the resulting records:

      def resultCount = criteria.updateAll(myInt: 20)

      The bug seems to be located in org.grails.datastore.mapping.query.jpa.JpaQueryBuilder:586 where the query is appended to the projection and not to the selection part.
      The resulting query then looks like:

      UPDATE grails_ilike.MyDomain myDomain SET myDomain.myInt=?lower(myDomain.myString) like lower(?) WHERE (myDomain.myInt=? AND )
      

        Activity

        Show
        Graeme Rocher added a comment - fixed by https://github.com/SpringSource/grails-data-mapping/commit/23ac1ccc6545edbe22c6e0c9aef463171a70f705

          People

          • Assignee:
            Graeme Rocher
            Reporter:
            Clemens Schneider
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development