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

   I observed inconsistent behavior and API when trying to reuse and compose 
DetachedCriteria instances together:
   - Criteria composition seems to only work with closure based detached 
criterias
   - It seems there is no way to compose two detached criteria instances 
together (`DetachedCriteria.where(DetachedCriteria)`)
   - closure based detached criterias do not work in a type-safe environment 
@GrailsCompileStatic
   
   Tested with **Grails 3.2.4**
   
   Some examples to demonstrate 
   ```
   // this is the only variant that works
   def myFilter = {} as DetachedCriteria<Person>
   Person.where(myFilter)
   ```
   ```
   // this doesn't work, resulting in exception:
   // No signature of method: Person.where() is applicable for argument types: 
(grails.gorm.DetachedCriteria)
   def myFilter = new DetachedCriteria(Person).build {}
   Person.where(myFilter)
   ```
   ```
   // type-safe variant mit @GrailsCompileStatic doesn't even compile:
   // [Static type checking] - Cannot assign value of type groovy.lang.Closure 
<Person> to variable of type grails.gorm.DetachedCriteria <Person>
   DetachedCriteria<Person> myFilter = {} as DetachedCriteria<Person>
   Person.where(myFilter)
   ```
   ```
   // DetachedCriteria closure coercion inconsistency:
   def myCriteria = {} as DetachedCriteria<Person>
   log.debug "${myCriteria instanceof DetachedCriteria}" // -> false
   
   def myPredicate = {} as Predicate
   log.debug "${myPredicate instanceof Predicate}" // -> true
   ```
   


-- 
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