jamesfredley opened a new pull request, #15424:
URL: https://github.com/apache/grails-core/pull/15424

   ## Summary
   - `AbstractDetachedCriteria.clone()` was missing `connectionName`, 
`lazyQuery`, and `associationCriteriaMap`
   - This caused `withConnection()` settings to be silently lost when chained 
methods like `max()`, `offset()`, or `sort()` were called afterward, because 
each internally clones the criteria
   
   ## Example of the bug
   ```groovy
   def criteria = Product.where { amount > 100 }
       .withConnection('secondary')
       .max(10)  // clones internally, loses connectionName
   
   criteria.list()  // queries DEFAULT datasource instead of 'secondary'
   ```
   
   ## Changes
   - **`AbstractDetachedCriteria.clone()`**: Added copying of `connectionName`, 
`lazyQuery`, and `associationCriteriaMap` (as a shallow copy)
   - **`DetachedCriteriaCloneSpec`**: 7 new unit tests verifying clone 
preserves all fields, creates independent map copies, and that 
`withConnection().max()` chaining works correctly
   
   ## Test Results
   - `DetachedCriteriaCloneSpec`: 7/7 pass
   - `codeStyle`: pass
   
   Fixes #15422
   
   Reproducer: 
https://github.com/jamesfredley/grails-detachedcriteria-clone-connection


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