Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

support backtick enquoting in SQL script splitter #8593

Merged
merged 2 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading