bmrrossi / c5-db-migration

Automatically exported from code.google.com/p/c5-db-migration
0 stars 0 forks source link

Not handling comments on the same line as a statement #44

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a SQL file with the following contents:

CREATE TABLE TableName (
  someField VARCHAR(20) NOT NULL, -- A comment
  anotherField VARCHAR(255), -- Another comment
  CONSTRAINT PK_TableName PRIMARY KEY (someField);
);

2. Run mvn db-migration:migrate -Ptest (or similar) 
3. Observer error.

java.sql.SQLException: Incorrect syntax near ','.
        at com.carbonfive.db.jdbc.ScriptRunner.doExecute(ScriptRunner.java:127)
        at com.carbonfive.db.jdbc.ScriptRunner.execute(ScriptRunner.java:38)
        at com.carbonfive.db.migration.SQLScriptMigration.migrate(SQLScriptMigration.java:32)
        at com.carbonfive.db.migration.DataSourceMigrationManager$1.doInConnection(DataSourceMigrationManager.java:100)
        at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:341)
        at com.carbonfive.db.migration.DataSourceMigrationManager.migrate(DataSourceMigrationManager.java:80)
        at com.carbonfive.db.migration.maven.MigrateMojo.executeMojo(MigrateMojo.java:19)
        at com.carbonfive.db.migration.maven.AbstractMigrationMojo.execute(AbstractMigrationMojo.java:72)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:454)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:559)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:513)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:483)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:331)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:292)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:345)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:132)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:290)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

What is the expected output? What do you see instead?
Expected output is a successful migration. Instead I receive an error caused by 
the fact that comments are not stripped from the script sent to the database, 
and that newlines are removed or not treated correctly.

What version of the product are you using? On what operating system?
Version 0.9.9 of the product.
Windows XP, and the database is MS SQL Server 2008 R2.

Please provide any additional information below.
From the source, it may seem that the problem occurs here 
http://code.google.com/p/c5-db-migration/source/browse/trunk/db-support/src/main
/java/com/carbonfive/db/jdbc/ScriptRunner.java#80

Original issue reported on code.google.com by tnicolay...@gmail.com on 2 Nov 2010 at 10:06