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 'string'as and no space in between #1578

Closed
svitalsky opened this issue Mar 28, 2017 · 2 comments
Closed

Comments

@svitalsky
Copy link

@svitalsky svitalsky commented Mar 28, 2017

What version of Flyway are you using?

4.0.3
4.1.2

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, version is irrelevant here (and I don't know right away)

What operating system are you using?

Windows 7 (ashamed of it, but it's a corporate env.)

What did you do?

I've run flyway:migrate command with a script containing "create or replace procedure" command. First within a script with a lot of other DDL commands, but for this one the slash at the end of the procedure definition was not removed but rather incorporated into the proc. body with all that followed.

Then I've tried to put that procedure into separate script: without slash it worked OK (so the SQL itself is correct), with the slash at the end it did not work (slash was added to the procedure body). Eventually, after removing parts of the procedure and trying again and again I've found out that the offending code was this:

select ... , '1'as "QUANTITY", ...

Notice the missing space between the second apostrophe and the "as" keyword (I didn't write the SQL, however it is perfectly legal to write it this way, and after all without slash it worked)! When I added a space there the script worked just fine. I suppose Flyway does some parsing and this missing space causes it to fail.

What did you expect to see?

Successful migration.

What did you see instead?

Unsuccessful migration with one stored proc not compiled and some other stuff missing (swallowed by that stored procedure not knowing where its end was).

Thank you.

@axelfontaine axelfontaine added this to the Flyway 4.2.0 milestone Apr 3, 2017
@axelfontaine axelfontaine changed the title Oracle slash once again Oracle statement fails when it contains 'string'as and no space in between Apr 3, 2017
axelfontaine added a commit to flyway/flywaydb.org that referenced this issue Apr 3, 2017
@axelfontaine
Copy link
Contributor

@axelfontaine axelfontaine commented Apr 3, 2017

Thanks for analysing. The as keyword with no space preceding it was indeed the issue.

@Nthalk
Copy link

@Nthalk Nthalk commented Nov 29, 2017

@aaltergot There is a missing keyword in this list: DATE, the oracle date cast keyword.

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/22/2017'; -- << With a space between DATE and ', it works fine. Otherwise no.
  END F_MAGIC_DATE;

END DEMO_P_FLYWAYBUG;
/
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
Linked pull requests

Successfully merging a pull request may close this issue.

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