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

Parser confused by MySQL IF function #2861

Closed
wkiszka opened this issue Jun 19, 2020 · 0 comments
Closed

Parser confused by MySQL IF function #2861

wkiszka opened this issue Jun 19, 2020 · 0 comments
Assignees
Milestone

Comments

@wkiszka
Copy link

@wkiszka wkiszka commented Jun 19, 2020

Which version and edition of Flyway are you using?

6.4.4 community

If this is not the latest version, can you reproduce the issue with the latest one as well?

(Many bugs are fixed in newer releases and upgrading will often resolve the issue)

Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)

Command-line

Which database are you using (type & version)?

MySQL 8.0

Which operating system are you using?

Ubuntu 18.04

What did you do?

(Please include the content causing the issue, any relevant configuration settings, the SQL statement that failed (if relevant) and the command you ran.)

CREATE OR REPLACE VIEW vw_if_function AS
SELECT
  IF((1 = 1), 1, 0) as col_1,
  IF((2 = 2), 2, 0) as col_2,
  -- END IF
  CASE
    WHEN 3 = 3
    THEN (SELECT 3)
    ELSE (SELECT 9)
  END AS col_3
;
What did you expect to see?

A view with three columns

What did you see instead?
Caused by: org.flywaydb.core.api.FlywayException: Incomplete statement at line 1 col 1: CREATE OR REPLACE VIEW vw_if_function AS
SELECT
  IF((1 = 1), 1, 0) as col_1,
  IF((2 = 2), 2, 0) as col_2,
  -- END IF
  CASE
    WHEN 3 = 3
    THEN (SELECT 3)
    ELSE (SELECT 9)
  END AS col_3
;
	at org.flywaydb.core.internal.parser.Parser.getNextStatement(Parser.java:224)
Some more information:

If you uncomment the "END IF" then the parser succeeds and the SQL is passed to the database, which of course returns a syntax error because the SQL is no longer valid.
Removing either the CASE or all the IFs will allow the parser to succeed.

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

No branches or pull requests

2 participants