From d9365051b3dae6a24d8fda1b8cc987c6f9002392 Mon Sep 17 00:00:00 2001 From: Austin Brougher Date: Sun, 15 May 2016 13:54:48 -0400 Subject: [PATCH] Fixed #27: SqlScriptReader is parsing string literals from comments. --- .../main/java/org/jumpmind/db/sql/SqlScriptReader.java | 9 ++++++--- symmetric-db/src/test/resources/test-script-1.sql | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/symmetric-db/src/main/java/org/jumpmind/db/sql/SqlScriptReader.java b/symmetric-db/src/main/java/org/jumpmind/db/sql/SqlScriptReader.java index 9a25107a38..615f2ca4cc 100644 --- a/symmetric-db/src/main/java/org/jumpmind/db/sql/SqlScriptReader.java +++ b/symmetric-db/src/main/java/org/jumpmind/db/sql/SqlScriptReader.java @@ -140,8 +140,9 @@ private final String removeComments(String s) { char prev = '\0'; int index = 0; for (char cur : characters) { - - literalInfo = switchLiteral(literalInfo, index, characters); + if (!inLineComment) { + literalInfo = switchLiteral(literalInfo, index, characters); + } if (literalInfo == null && !inLineComment && !inBlockComment) { inBlockComment = isBlockCommentStart(prev, cur); @@ -227,7 +228,9 @@ private final boolean checkStatementEnds(String s) { char prev = '\0'; int index = 0; for (char cur : characters) { - literalInfo = switchLiteral(literalInfo, index, characters); + if (!inLineComment) { + literalInfo = switchLiteral(literalInfo, index, characters); + } if (literalInfo == null && !inLineComment && !inBlockComment) { inBlockComment = isBlockCommentStart(prev, cur); diff --git a/symmetric-db/src/test/resources/test-script-1.sql b/symmetric-db/src/test/resources/test-script-1.sql index 3d53dc8c35..003deb9839 100644 --- a/symmetric-db/src/test/resources/test-script-1.sql +++ b/symmetric-db/src/test/resources/test-script-1.sql @@ -19,6 +19,8 @@ -- under the License. -- +-- This is a comment with a single literal. It's + -- This is a comment select * from TEST where