Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When to support grails 3.3? #141

Closed
kevinclcn opened this issue Jan 31, 2018 · 5 comments
Closed

When to support grails 3.3? #141

kevinclcn opened this issue Jan 31, 2018 · 5 comments
Assignees
Milestone

Comments

@kevinclcn
Copy link

kevinclcn commented Jan 31, 2018

Steps to Reproduce

Per this link grails/gorm-hibernate5#25, the correct multiple datasources config syntax for grails 3.3 is:

dataSource:
    # primary dataSource config ("dataSource")
dataSources:
    secondary:
        # secondary dataSource config ("dataSource_secondary")

rather than:

dataSources:
    dataSource:
        # primary dataSource config ("dataSource")
    secondary:
        # secondary dataSource config ("dataSource_secondary")

But the grails-database-migration tool supports only the second format. I've tried to provide a PR for quick fix, but it broken lots of tests since grails 3.3's test framework has been changed totally. #140

@kevinclcn
Copy link
Author

Hi @graemerocher @jameskleeh,

Have you been aware of this?

@jameskleeh
Copy link
Contributor

jameskleeh commented Mar 28, 2018

@kevinclcn Have you tried version 3.0.3 of the plugin? As far as I can tell it's fixed there

754ad2f

@kevinclcn
Copy link
Author

hi @jameskleeh , I created a demo for this issue: https://github.com/kevinclcn/dbmigrationIssue

clone it and run ./gradlew dbmUpdate, it would complain:

    Command execution error: Cannot get property 'password' on null object
    :dbmUpdate FAILED 

But once I commented out the second datasource(the app datasource in application.yml), the migration works fine.

I problem I found is in the method DatebaseMigrationCommand::getDataSourceConfig(), see the pr:

https://github.com/grails-plugins/grails-database-migration/pull/140/files

@longwa
Copy link

longwa commented Apr 19, 2018

We are having the same issue, the application starts up and runs migrations ok but commands like dbm-gorm-diff fail if you don't have a dataSource inside the dataSources block still.

@longwa
Copy link

longwa commented Apr 19, 2018

Actually, the problem is that the commands have their own config helper:

    Map<String, String> getDataSourceConfig(ConfigMap config = this.config) {
        def dataSourceName = dataSource ?: 'dataSource'
        def dataSources = config.getProperty('dataSources', Map) ?: [:]
        if (!dataSources) {
            def defaultDataSource = config.getProperty('dataSource', Map)
            if (defaultDataSource) {
                dataSources['dataSource'] = defaultDataSource
            }
        }
        return (Map<String, String>) dataSources.get(dataSourceName)
    }

Which isn't aware of the new syntax. When the application is bootstrapped the dataSource is injected but for the commands it tries to resolve it incorrectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants