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

Not worked migration when plsql contains CASE statement #2604

Merged
merged 1 commit into from Dec 18, 2019

Conversation

codicuz
Copy link
Contributor

@codicuz codicuz commented Dec 18, 2019

When migration is:
`CREATE OR REPLACE PACKAGE test AS
LS_TEST_IDENTIFIERS VARCHAR2(1 CHAR) := 'R';
FUNCTION FT( AS_IDENTIFIER VARCHAR2 ) RETURN VARCHAR2;
END TEST;
/

CREATE OR REPLACE PACKAGE BODY TEST AS
FUNCTION FT (AS_IDENTIFIER VARCHAR2) RETURN VARCHAR2 IS
BEGIN
CASE LS_TEST_IDENTIFIERS
WHEN 'R' THEN
RETURN AS_IDENTIFIER;
END CASE ;
END FT;
END TEST;
/
`
and method adjustBlockDepth is:

` @OverRide
protected void adjustBlockDepth(ParserContext context, List tokens, Token keyword) {
String keywordText = keyword.getText();
int parensDepth = keyword.getParensDepth();

    if ("BEGIN".equals(keywordText) || "CASE".equals(keywordText)
            || (("IF".equals(keywordText) || "LOOP".equals(keywordText)) && !containsWithinLast(1, tokens, parensDepth, "END"))
            || ("TRIGGER".equals(keywordText) && containsWithinLast(1, tokens, parensDepth, "COMPOUND"))
            || (("AS".equals(keywordText) || "IS".equals(keywordText)) && (
            containsWithinLast(4, tokens, parensDepth, "PACKAGE")
                    || containsWithinLast(3, tokens, parensDepth, "PACKAGE", "BODY")
                    || containsWithinLast(3, tokens, parensDepth, "TYPE", "BODY")))
    ) {
        context.increaseBlockDepth();
    } else if ("END".equals(keywordText)) {
        context.decreaseBlockDepth();
    }
}`

migration not worked.

But, if method adjustBlockDepth is:
` @OverRide
protected void adjustBlockDepth(ParserContext context, List tokens, Token keyword) {
String keywordText = keyword.getText();
int parensDepth = keyword.getParensDepth();

    if ("BEGIN".equals(keywordText) || (("IF".equals(keywordText)
            || "CASE".equals(keywordText) || "LOOP".equals(keywordText)) && !containsWithinLast(1, tokens, parensDepth, "END"))
            || ("TRIGGER".equals(keywordText) && containsWithinLast(1, tokens, parensDepth, "COMPOUND"))
            || (("AS".equals(keywordText) || "IS".equals(keywordText)) && (
            containsWithinLast(4, tokens, parensDepth, "PACKAGE")
                    || containsWithinLast(3, tokens, parensDepth, "PACKAGE", "BODY")
                    || containsWithinLast(3, tokens, parensDepth, "TYPE", "BODY")))
    ) {
        context.increaseBlockDepth();
    } else if ("END".equals(keywordText)) {
        context.decreaseBlockDepth();
    }
}`

migration ok.

@claassistantio
Copy link

@claassistantio claassistantio commented Dec 18, 2019

CLA assistant check
All committers have signed the CLA.

@codicuz codicuz changed the title Not worked migration when plsql with CASE statement Not worked migration when plsql contains CASE statement Dec 18, 2019
@juliahayward juliahayward self-assigned this Dec 18, 2019
@juliahayward
Copy link
Member

@juliahayward juliahayward commented Dec 18, 2019

Many thanks! I've written a regression test and can confirm the fix is all good to go as soon as you sign the CLA.

@alextercete alextercete added this to the Flyway 6.1.3 milestone Dec 18, 2019
@juliahayward juliahayward merged commit 977c73c into flyway:master Dec 18, 2019
2 checks passed
@juliahayward
Copy link
Member

@juliahayward juliahayward commented Dec 18, 2019

Just to confirm we'll also ship this in v6.1.3.

dohrayme pushed a commit to dohrayme/flyway that referenced this issue Feb 3, 2020
Not worked migration when plsql contains CASE statement
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

Successfully merging this pull request may close these issues.

None yet

4 participants