Skip to content

Support comments within SQL statements in JdbcTestUtils [SPR-9982] #14616

@spring-projects-issues

Description

@spring-projects-issues

Joram Agten opened SPR-9982 and commented

Status Quo

Executing an SQL script via JdbcTestUtils.executeSqlScript() with the following content fails.

INSERT INTO persons( person_id
                   , name)
VALUES( 1      -- person_id
      , 'Name' --name
);
org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [INSERT INTO persons( person_id                   , name)VALUES( 1      - person_id      , 'Name' --name)]; nested exception is java.sql.SQLSyntaxErrorException: ORA-00917: missing comma

Proposed Solutions

  1. keep the carriage returns after each line when building statements (line 388 389)
  2. strip all characters (per line) after the DEFAULT_COMMENT_PREFIX (including the prefix)

I think solution 1 is preferred, since 2 might become db dependent.

Deliverables

  1. Ensure that multi-line statements which contain comments can be executed.

Affects: 3.1.3

Issue Links:

Referenced from: commits 8a422f4, d0f687f

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)in: testIssues in the test moduletype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions