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

ScriptUtils and ScriptStatementFailedException confuse lines and statements [SPR-12752] #17349

Closed
spring-issuemaster opened this issue Feb 25, 2015 · 2 comments

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

commented Feb 25, 2015

Johannes Mockenhaupt opened SPR-12752 and commented

I'm using a ResourceDatabasePopulator to initialize a DB for tests. If a SQL statements fails (and continueOnError is false) an exception like this is raised:

org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement at line 7 of resource class path resource [sql/test-data-insert.sql]: INSERT INTO [...]
at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:474) ~[spring-jdbc-4.0.6.RELEASE.jar:4.0.6.RELEASE]

The issue is that the exception message is misleading. The statement in question is in line 16 (with comments and blank lines in between), which is the 7th statement. It seems the lineNumber variable doesn't refer to line numbers but rather to parsed statements.


Affects: 4.0.6

Referenced from: commits 45a80fa, 8f228d1, 291b3de, 448c99f, c0e550c, 23d52d5, 0f95c81

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Feb 25, 2015

Juergen Hoeller commented

I've revised the message to refer to a statement number instead. We're indeed counting parsed statements there, not lines in the source file.

Juergen

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Feb 27, 2015

Sam Brannen commented

Both ScriptUtils and ScriptStatementFailedException now properly refer to statement numbers instead of line numbers.

See the following GitHub commits for details:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.