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

JdbcTestUtils should not interpret comments as a separate statement [SPR-9593] #14227

Closed
spring-projects-issues opened this issue Jul 13, 2012 · 2 comments
Assignees
Labels
in: test type: bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jul 13, 2012

Johannes Odland opened SPR-9593 and commented

Overview

The splitSqlScripts() method in JdbcTestUtils splits scripts at a given delimiter, often ';'. If the script has a trailing comment this will be returned as a separate statement. When executing the statements an exception will be thrown.

Steps to Reproduce

If you call SimpleJdbcTestUtils.executeSqlScript() on the following script, the trailing comment will be detected as a separate statement and executed, resulting in a BadSqlGrammarException.

CREATE SQEUENCE HIBERNATE_SEQUENCE;
-- End of script

Affects: 3.1.2

Sub-tasks:

Issue Links:

Referenced from: commits 397d20b, 4aaf014, d8dc4a2

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Oct 21, 2012

Sam Brannen commented

Fixed as described in the comments for GitHub commit 4aaf014cc6:

Support comments in SQL scripts in JdbcTestUtils

Prior to this commit, utility methods in JdbcTestUtils interpreted SQL comments as separate statements, resulting in an exception when such a script is executed.

This commit addresses this issue by introducing a readScript(lineNumberReader, String) method that accepts a comment prefix. Comment lines are therefore no longer returned in the parsed script. Furthermore, the existing readScript(lineNumberReader) method now delegates to this new readScript() method, supplying "--" as the default comment prefix.

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Oct 26, 2012

Chris Beams commented

Now backported to 3.1.x:

commit d8dc4a257afa2aad9575e4d17a283935735f949e
Author: Sam Brannen <sam@sambrannen.com>
Commit: Chris Beams <cbeams@vmware.com>

    Support comments in SQL scripts in JdbcTestUtils
    
    Prior to this commit, utility methods in JdbcTestUtils interpreted SQL
    comments as separate statements, resulting in an exception when such a
    script is executed.
    
    This commit addresses this issue by introducing a
    readScript(lineNumberReader, String) method that accepts a comment
    prefix. Comment lines are therefore no longer returned in the parsed
    script. Furthermore, the existing readScript(lineNumberReader) method
    now delegates to this new readScript() method, supplying "--" as the
    default comment prefix.
    
    Issue: SPR-9593
    Backport-Commit: 4aaf014cc6bed8bdeea375556b1022066359e79d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test type: bug
Projects
None yet
Development

No branches or pull requests

2 participants