jamesfredley commented on code in PR #15395:
URL: https://github.com/apache/grails-core/pull/15395#discussion_r2824579576
##########
grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/services/implementers/FindAndDeleteImplementer.groovy:
##########
@@ -71,14 +74,27 @@ class FindAndDeleteImplementer extends FindOneImplementer
implements SingleResul
@Override
protected Statement buildReturnStatement(ClassNode targetDomainClass,
MethodNode abstractMethodNode, Expression queryMethodCall, Expression args,
MethodNode newMethodNode) {
VariableExpression var = varX('$obj', targetDomainClass)
- MethodCallExpression deleteCall = args != null ? callX(var, 'delete',
args) : callX(var, 'delete')
-
- deleteCall.setSafe(true) // null safe
- block(
- declS(var, queryMethodCall),
- stmt(deleteCall),
- returnS(var)
- )
+ Expression connectionId = findConnectionId(newMethodNode)
+ if (connectionId != null) {
+ // Route delete through the instance API for the specified
connection
+ block(
+ declS(var, queryMethodCall),
+ ifS(
+ notNullX(var),
+ stmt(callX(buildInstanceApiLookup(targetDomainClass,
connectionId), 'delete', new ArgumentListExpression(var)))
Review Comment:
Not applicable. The connection-aware branch calls
`buildInstanceApiLookup(targetDomainClass, connectionId).delete(var)` which
routes through `GormInstanceApi.delete()`. The `args` map (`flush`, `validate`,
etc.) is for the direct `obj.delete(args)` GORM call - the instance API handles
flush/validation internally via its own configuration. Passing `args` to the
instance API's `delete()` method would require a different method signature
that doesn't exist on `GormInstanceApi`.
--
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]