sbglasius opened a new issue, #14420:
URL: https://github.com/apache/grails-core/issues/14420

   When doing a query with a `.find { }` method on a domain object (in this 
case in a Grails 4.0.11 application) the generated detached criteria does not 
contain the criteria defined in code. 
   
   Example:
   ```
       def "test where query is in then block with def"() {
           given:
           Bundle bundle = new Bundle(name: 'bundle')
           bundle.addToVersions(name: '1.0')
           bundle.save(flush: true)
   
           when:
           bundle.addToVersions(name: '1.1')
           bundle.save(flush: true)
   
           then:
           def result = BundleVersion.find({ name == '1.1' && bundle.name == 
'bundle' })
           result.name == '1.1'
       }
   ``` 
   where the `result` is a variable, then it works. But if the variable is 
omitted like this:
   ``` 
       def "test where query is in then block without def"() {
           given:
           Bundle bundle = new Bundle(name: 'bundle')
           bundle.addToVersions(name: '1.0')
           bundle.save(flush: true)
   
           when:
           bundle.addToVersions(name: '1.1')
           bundle.save(flush: true)
   
           then: "this will fail - which is not expected"
           BundleVersion.find({ name == '1.1' && bundle.name == 'bundle' 
}).name == '1.1'
       }
   ``` 
   Then `1.0` is found which is unexpected.
   
   An example of this behaviour can be found here: 
https://github.com/sbglasius/gorm-query-bug
   
   Discovered by @thomas58


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to