Comments (6)
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 followingBEGIN
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.
from flyway.
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.
{
"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.
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.
from flyway.
It looks like it's been fixed then. I'll upgrade to Flyway 10.11.1 and try it again
from flyway.
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)
- Unsupported Database: MySQL 8.0
- Artifact flyway-parent is missing starting from 10.11.1 version HOT 3
- An API incompatibility was encountered HOT 1
- Add jackson-core to drivers HOT 4
- Flyway says ` No database found to handle jdbc:postgresql://localhost:5432/postgres` when using java migrator in jar only HOT 5
- Flyway version is not compatible with GLIBC library
- Error Unable to obtain connection from database for user postgres SQL State : 08001 HOT 3
- Why flyway cannot execute sql again when last time execution failed? HOT 2
- Debloat flyway core
- Trigger delimiter problem (again?)
- Support failed missing migration with ignoreMigrationPatterns HOT 2
- Constants migrate flyway-maven-plugin 5.2.4 -> 6.x
- ignoreMigrationPatterns: missing pattern does not work for if a future migration is missing
- Update Spanner Database dependencies. HOT 2
- No database found to handle when org.gradle.configuration-cache=true HOT 2
- Support for Postgres 14 HOT 2
- flyway migrate hangs indefinitely when using DECLARE
- Compatibility with H2 2.2.224 HOT 1
- Issue with mongo-jdbc-driver dependency HOT 2
- Commitment to how transactions are handled in beforeEachMigrate and afterEachMigrate callbacks HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flyway.