From 280fe496a0942afb4df06950efad0ede1fee3bf3 Mon Sep 17 00:00:00 2001 From: Yasuharu Nakano Date: Wed, 19 Feb 2025 23:38:28 -0500 Subject: [PATCH 1/2] Remove "dataSource_" from bean name as dataSourceName of GroovyChange when using additional dataSources --- .../plugins/databasemigration/liquibase/GroovyChange.groovy | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grails-database-migration/src/main/groovy/org/grails/plugins/databasemigration/liquibase/GroovyChange.groovy b/grails-database-migration/src/main/groovy/org/grails/plugins/databasemigration/liquibase/GroovyChange.groovy index 8eed54b60..4f275d6bb 100644 --- a/grails-database-migration/src/main/groovy/org/grails/plugins/databasemigration/liquibase/GroovyChange.groovy +++ b/grails-database-migration/src/main/groovy/org/grails/plugins/databasemigration/liquibase/GroovyChange.groovy @@ -90,6 +90,9 @@ class GroovyChange extends AbstractChange { void load(ParsedNode parsedNode, ResourceAccessor resourceAccessor) throws ParsedNodeException { ctx = parsedNode.getChildValue(null, 'applicationContext', ApplicationContext) dataSourceName = parsedNode.getChildValue(null, DATA_SOURCE_NAME_KEY, String) + if (dataSourceName.startsWith("dataSource_")) { + dataSourceName = dataSourceName.substring("dataSource_".length()) + } initClosure = parsedNode.getChildValue(null, 'init', Closure) initClosure?.setResolveStrategy(Closure.DELEGATE_FIRST) From 76e17c107a8fb0eaeba95f75aa18c44b96a6928a Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Wed, 19 Feb 2025 23:54:02 -0500 Subject: [PATCH 2/2] Nullsafe --- .../plugins/databasemigration/liquibase/GroovyChange.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grails-database-migration/src/main/groovy/org/grails/plugins/databasemigration/liquibase/GroovyChange.groovy b/grails-database-migration/src/main/groovy/org/grails/plugins/databasemigration/liquibase/GroovyChange.groovy index 4f275d6bb..c90d7a714 100644 --- a/grails-database-migration/src/main/groovy/org/grails/plugins/databasemigration/liquibase/GroovyChange.groovy +++ b/grails-database-migration/src/main/groovy/org/grails/plugins/databasemigration/liquibase/GroovyChange.groovy @@ -90,7 +90,7 @@ class GroovyChange extends AbstractChange { void load(ParsedNode parsedNode, ResourceAccessor resourceAccessor) throws ParsedNodeException { ctx = parsedNode.getChildValue(null, 'applicationContext', ApplicationContext) dataSourceName = parsedNode.getChildValue(null, DATA_SOURCE_NAME_KEY, String) - if (dataSourceName.startsWith("dataSource_")) { + if (dataSourceName?.startsWith("dataSource_")) { dataSourceName = dataSourceName.substring("dataSource_".length()) }