Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-9982

Support comments within SQL statements in JdbcTestUtils

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 3.1.3
    • Fix Version/s: 3.2 GA
    • Component/s: Data:JDBC, Test
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              sbrannen Sam Brannen
              Reporter:
              joram.agten Joram Agten
              Last updater:
              Spring Issues Spring Issues
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                3 years, 24 weeks, 5 days ago