Code Monkey home page Code Monkey logo

Comments (6)

JasonLuo-Redgate avatar JasonLuo-Redgate commented on June 18, 2024

Hi @Phil-Factor ,

I looked into the issue posted and here are my findings:

  • I copied the exact afterInfo__Toggle.sql file, but I got a different error message: Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near 'the'.

  • This was caused by this line --if flyway.placeholders.Turnit=off BEGIN /* the start of the block that you excecute to switch. The root cause is that the -- commented out the following BEGIN key word since they are in the same line.

  • After fixing that (Start a new line for that BEGIN key word), the statement works fine now.

image

from flyway.

Phil-Factor avatar Phil-Factor commented on June 18, 2024

My sample somehow got mangled during the paste-in process, The code used to work fine and hasn't changed. All I did was to upgrade flyway. Obviously, when the error happened, I removed the initial comment block and it then worked fine.

/*
Before this code can be used in a callback, you must have the following
default value for flyway.placeholders.Toggle set in the project flyway.conf
otherwise you'll get an error.
	flyway.placeholders.Toggle=Yes 
To turn the toggle on, use flyway.placeholders.Turnit=on otherwise
flyway.placeholders.Turnit=on
in the commandline, this will look like …
flyway info '-placeholders.Toggle=Yes' '-placeholders.Turnit=on' 
You will, of course, need to add the DCL code that adds or removes
membership of the users roles (e.g. HR, Accounts) to the role that
allows access

*/

IF ('${Toggle}' = 'Yes')
  BEGIN --only execute this if flyway.placeholders.Toggle=Yes
    IF ('on' = '${TurnIt}') --if flyway.placeholders.Turnit=on
      BEGIN /* the start of the block that you excecute to switch
	  the toggle on */
        SELECT 'We have executed the code for turning the feature on';
      END;
    ELSE IF ('off' = '${TurnIt}')--if flyway.placeholders.Turnit=off
      BEGIN /* the start of the block that you excecute to switch
	  the toggle off */
        SELECT 'We have executed the code for turning the feature off';
      END;
    ELSE
      BEGIN
        SELECT 'We couldn''t recognise your ''${TurnIt}'' instructiions';
      END;
  END;

from flyway.

Phil-Factor avatar Phil-Factor commented on June 18, 2024

{
"error": {
"errorCode": "ERROR",
"message": "Unable to parse statement in .\migrations\Callbacks\afterInfo__Toggle.sql at line 1 col 1. See https://rd.gt/3ipi7Pm for more information. Input length = 1",
"stackTrace": null,
"lineNumber": null,
"path": null,
"cause": {
"message": "Input length = 1",
"stackTrace": "java.nio.charset.MalformedInputException: Input length = 1\r\n\tat java.base/java.nio.charset.CoderResult.throwException(Unknown Source)\r\n\tat java.base/sun.nio.cs.StreamDecoder.implRead(Unknown Source)\r\n\tat java.base/sun.nio.cs.StreamDecoder.read(Unknown Source)\r\n\tat java.base/java.io.BufferedReader.fill(Unknown Source)\r\n\tat java.base/java.io.BufferedReader.read(Unknown Source)\r\n\tat org.flywaydb.core.internal.parser.UnboundedReadAheadReader.read(UnboundedReadAheadReader.java:55)\r\n\tat java.base/java.io.FilterReader.read(Unknown Source)\r\n\tat org.flywaydb.core.internal.util.BomStrippingReader.read(BomStrippingReader.java:40)\r\n\tat java.base/java.io.FilterReader.read(Unknown Source)\r\n\tat org.flywaydb.core.internal.parser.PlaceholderReplacingReader.read(PlaceholderReplacingReader.java:117)\r\n\tat java.base/java.io.FilterReader.read(Unknown Source)\r\n\tat org.flywaydb.core.internal.parser.PositionTrackingReader.read(PositionTrackingReader.java:33)\r\n\tat java.base/java.io.FilterReader.read(Unknown Source)\r\n\tat org.flywaydb.core.internal.parser.RecordingReader.read(RecordingReader.java:33)\r\n\tat java.base/java.io.FilterReader.read(Unknown Source)\r\n\tat org.flywaydb.core.internal.parser.PeekingReader.refillPeekBuffer(PeekingReader.java:73)\r\n\tat org.flywaydb.core.internal.parser.PeekingReader.peek(PeekingReader.java:187)\r\n\tat org.flywaydb.core.internal.parser.PeekingReader.peek(PeekingReader.java:169)\r\n\tat org.flywaydb.core.internal.parser.Parser.readToken(Parser.java:470)\r\n\tat org.flywaydb.core.internal.parser.Parser.getNextStatement(Parser.java:171)\r\n\tat org.flywaydb.core.internal.parser.Parser$ParserSqlStatementIterator.next(Parser.java:733)\r\n\tat org.flywaydb.core.internal.parser.Parser$ParserSqlStatementIterator.next(Parser.java:698)\r\n\tat org.flywaydb.core.internal.sqlscript.ParserSqlScript.parse(ParserSqlScript.java:71)\r\n\tat org.flywaydb.core.internal.sqlscript.ParserSqlScript.validate(ParserSqlScript.java:112)\r\n\tat org.flywaydb.core.internal.sqlscript.ParserSqlScript.executeInTransaction(ParserSqlScript.java:177)\r\n\tat org.flywaydb.core.internal.callback.SqlScriptCallbackFactory$SqlScriptCallback.canHandleInTransaction(SqlScriptCallbackFactory.java:107)\r\n\tat org.flywaydb.core.internal.callback.DefaultCallbackExecutor.execute(DefaultCallbackExecutor.java:118)\r\n\tat org.flywaydb.core.internal.callback.DefaultCallbackExecutor.onEvent(DefaultCallbackExecutor.java:66)\r\n\tat org.flywaydb.core.internal.command.DbInfo.info(DbInfo.java:56)\r\n\tat org.flywaydb.core.Flyway.lambda$info$1(Flyway.java:227)\r\n\tat org.flywaydb.core.FlywayExecutor.execute(FlywayExecutor.java:205)\r\n\tat org.flywaydb.core.Flyway.info(Flyway.java:226)\r\n\tat org.flywaydb.commandline.Main.executeOperation(Main.java:265)\r\n\tat org.flywaydb.commandline.Main.executeFlyway(Main.java:171)\r\n\tat org.flywaydb.commandline.Main.main(Main.java:114)\r\n",
"cause": null
}
}
}

from flyway.

JasonLuo-Redgate avatar JasonLuo-Redgate commented on June 18, 2024

Hi @Phil-Factor ,

I have copied the exact new text format you posted, but I couldn't reproduce this error.
The SQL Callback is running fine locally.

image

image

from flyway.

Phil-Factor avatar Phil-Factor commented on June 18, 2024

It looks like it's been fixed then. I'll upgrade to Flyway 10.11.1 and try it again

from flyway.

JasonLuo-Redgate avatar JasonLuo-Redgate commented on June 18, 2024

Many thanks @Phil-Factor. I will keep this ticket open for a while and welcome to raise any questions if this issue persists.

from flyway.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.