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

Update failed for MSSQL scripts containing 'Go' #868

Closed
mikhailChibel opened this issue Oct 23, 2014 · 2 comments
Closed

Update failed for MSSQL scripts containing 'Go' #868

mikhailChibel opened this issue Oct 23, 2014 · 2 comments
Milestone

Comments

@mikhailChibel
Copy link

@mikhailChibel mikhailChibel commented Oct 23, 2014

I have an IndexOutOfBounds -1 exception when trying to run maven flyway:migrate on my project. The target database is MSSQL. We've managed to pinpoint problem and it appeared that one of our script were using mixed cased "Go" which actually caused the problem

The script which caused the problem:

    BEGIN TRANSACTION
    ALTER TABLE dbo.asset ADD total_extras_price numeric(19, 2) NULL;
    Go
    COMMIT TRANSACTION

The problematic code is in SqlStatementBuilder#stripDelimiter method, which can not handle mixed casing Go.

    /* private -> testing */
        static String stripDelimiter(String sql, Delimiter delimiter) {
            final int lowerCaseIndex = sql.lastIndexOf(delimiter.getDelimiter().toLowerCase());
            final int upperCaseIndex = sql.lastIndexOf(delimiter.getDelimiter().toUpperCase());
            return sql.substring(0, Math.max(lowerCaseIndex, upperCaseIndex));
        }
@axelfontaine axelfontaine added this to the Flyway 3.1 milestone Oct 24, 2014
@axelfontaine axelfontaine changed the title Update filed for MSSQL scripts containing 'Go' Update failed for MSSQL scripts containing 'Go' Nov 21, 2014
@axelfontaine
Copy link
Contributor

@axelfontaine axelfontaine commented Nov 21, 2014

Thanks for the report. The previous solution was something I was never happy with, so it was good to revisit it once and for all. Fixed.

@mikhailChibel
Copy link
Author

@mikhailChibel mikhailChibel commented Nov 23, 2014

Thanks Axel for the fix, I really appreciate it.

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.