Skip to content

Commit 9b780dd

Browse files
authored
Add support for backtick enquoting in SQL script splitter (#8593)
1 parent 8b9eb0c commit 9b780dd

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

modules/database-commons/src/main/java/org/testcontainers/ext/ScriptScanner.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,12 @@ Lexem next() {
141141
return Lexem.SEPARATOR;
142142
} else if (matchesSingleLineComment() || matchesMultilineComment()) {
143143
return Lexem.COMMENT;
144-
} else if (matchesQuotedString('\'') || matchesQuotedString('"') || matchesDollarQuotedString()) {
144+
} else if (
145+
matchesQuotedString('\'') ||
146+
matchesQuotedString('"') ||
147+
matchesQuotedString('`') ||
148+
matchesDollarQuotedString()
149+
) {
145150
return Lexem.QUOTED_STRING;
146151
} else if (matches(identifier)) {
147152
return Lexem.IDENTIFIER;

modules/database-commons/src/test/java/org/testcontainers/ext/ScriptSplittingTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ public void testIssue1547Case2() {
6868
splitAndCompare(script, expected);
6969
}
7070

71+
@Test
72+
public void testSplittingEnquotedSemicolon() {
73+
String script = "CREATE TABLE `bar;bar` (\n" + " end_time VARCHAR(255)\n" + ");";
74+
75+
List<String> expected = Arrays.asList("CREATE TABLE `bar;bar` ( end_time VARCHAR(255) )");
76+
77+
splitAndCompare(script, expected);
78+
}
79+
7180
@Test
7281
public void testUnusualSemicolonPlacement() {
7382
String script = "SELECT 1;;;;;SELECT 2;\n;SELECT 3\n; SELECT 4;\n SELECT 5";

0 commit comments

Comments
 (0)