Skip to content

Commit

Permalink
Add support for backtick enquoting in SQL script splitter (#8593)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterhalicky committed May 6, 2024
1 parent 8b9eb0c commit 9b780dd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,12 @@ Lexem next() {
return Lexem.SEPARATOR;
} else if (matchesSingleLineComment() || matchesMultilineComment()) {
return Lexem.COMMENT;
} else if (matchesQuotedString('\'') || matchesQuotedString('"') || matchesDollarQuotedString()) {
} else if (
matchesQuotedString('\'') ||
matchesQuotedString('"') ||
matchesQuotedString('`') ||
matchesDollarQuotedString()
) {
return Lexem.QUOTED_STRING;
} else if (matches(identifier)) {
return Lexem.IDENTIFIER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ public void testIssue1547Case2() {
splitAndCompare(script, expected);
}

@Test
public void testSplittingEnquotedSemicolon() {
String script = "CREATE TABLE `bar;bar` (\n" + " end_time VARCHAR(255)\n" + ");";

List<String> expected = Arrays.asList("CREATE TABLE `bar;bar` ( end_time VARCHAR(255) )");

splitAndCompare(script, expected);
}

@Test
public void testUnusualSemicolonPlacement() {
String script = "SELECT 1;;;;;SELECT 2;\n;SELECT 3\n; SELECT 4;\n SELECT 5";
Expand Down

0 comments on commit 9b780dd

Please sign in to comment.