-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
SQLServer: no exception thrown when statement fails #718
Comments
…s to execute properly flyway dosn't throw any exception as if patch was executed successfully
Thanks for the report? Which database are you using? Why would executeBatch() fix this? |
I use MSSQL.We also wondered why query passes without exceptions even if script is incorrect. The problem occured when we tried to create foreign key with wrong data type. Flyway ran patch, foreign key was not added to the table, but patch was marked as executed in schema_version table. Then I tried to use execute batch, because according to the spec it throws BatchUpdateException (a subclass of SQLException) if one of the commands sent to the database fails to execute properly or attempts to return a result set. |
It happens only with MSSQL, for hsqldb and mysql it is ok. |
Could you please advice, what should be done to make it work in MSSQL? If we do a local changes, we will not have possibility to update flyway, because updated version will still contain this bug.... |
I am facing exactly the same problem, using FlyWay 3.0 with SQL Azure (microsoft JDBC driver). |
I wrote a fix for this issue and sent a pull request: |
PR Merged. Thanks Carlo! |
We faced with such problem. When one of patch commands fails to execute properly(not first command), flyway does not throw any exceptions, and marks this patch as executed in schema_version table.
It can be reproduced in such way: just create patch with statements(should fail on ) to flyway-samle project and run it.
INSERT INTO test_user (name1) VALUES ('test');
INSERT INTO test_user (name1) VALUES ('test');
Patch should fail but it doesn't.
We investigated this problem and found reason of bug. On executing statement, JdbcTemplate uses execute method. But it would be better to use http://docs.oracle.com/javase/7/docs/api/java/sql/Statement.html#executeBatch%28%29
The text was updated successfully, but these errors were encountered: