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

Oracle statement fails when it contains DATE'11/29/2017' and no space in between #1846

Closed
Nthalk opened this issue Nov 29, 2017 · 1 comment

Comments

@Nthalk
Copy link

Nthalk commented Nov 29, 2017

What version of Flyway are you using?

4.2.0

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

Maven plugin

What database are you using (type & version)?

Oracle 11G

What operating system are you using?

Linux

What did you do?

(Please include the content causing the issue, any relevant configuration settings, and the command you ran)

CREATE OR REPLACE PACKAGE DEMO_P_FLYWAYBUG
IS
  FUNCTION F_MAGIC_DATE
    RETURN DATE;
END DEMO_P_FLYWAYBUG;
/

CREATE OR REPLACE PACKAGE BODY DEMO_P_FLYWAYBUG
IS
  FUNCTION F_MAGIC_DATE
    RETURN DATE
  IS BEGIN
    RETURN DATE'11/29/2017';
  END F_MAGIC_DATE;

END DEMO_P_FLYWAYBUG;
/
What did you expect to see?

That the USER_SOURCE for the package body object ends with 'END DEMO_P_FLYWAYBUG'
and that the package compiles.

What did you see instead?

That the USER_SOURCE for the package body object ends with '/'
and that the package does not compile.

I traced this bug to

if (endWithOpenMultilineStringLiteral() || insideMultiLineComment || isSingleLineComment(lineSimplified)) {
where it thinks it is in a multiline string.

This is because the DATE cast keyword is allowed before the strings. This is fixed with a space between DATE and the subsequent quote.

This can easily be fixed by adding DATE to the following list

private static final Pattern KEYWORDS_BEFORE_STRING_LITERAL_REGEX = Pattern.compile("^(N|IF|ELSIF|SELECT|IMMEDIATE|RETURN|IS)('.*)");

@axelfontaine axelfontaine added this to the Flyway 5.0.0 milestone Nov 29, 2017
axelfontaine pushed a commit to flyway/flywaydb.org that referenced this issue Nov 29, 2017
@axelfontaine
Copy link
Contributor

Good catch and excellent analysis! That was indeed the issue. Thank you very much. Fixed!

dohrayme pushed a commit to dohrayme/flyway that referenced this issue Feb 3, 2020
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