Skip to content
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
6 changes: 3 additions & 3 deletions src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt
Original file line number Diff line number Diff line change
Expand Up @@ -6992,10 +6992,10 @@ TOKEN:
lexUnicodeEscapeString(matchedToken);
}
}
| < S_QUOTED_IDENTIFIER: "\"" ( "\"\"" | ~["\n","\r","\""])* "\""
| < S_QUOTED_IDENTIFIER: "\"" ( "\"\"" | ~["\""])* "\""
// MySQL double-quoted string with backslash escapes; trimmed below when not enabled
| "\"" ( "\"\"" | "\\" ~["\n","\r"] | ~["\n","\r","\"","\\"])* "\""
| ("`" ("``" | ~["\n","\r","`"])* "`") | ( "[" (~["\n","\r","]"])* "]" ) >
| "\"" ( "\"\"" | "\\" ~[] | ~["\"","\\"])* "\""
| ("`" ("``" | ~["`"])* "`") | ( "[" (~["]"])* "]" ) >
{
if ( matchedToken.image.charAt(0) == '"' ) {
// Both alternatives above compete for the longest match. Keep the closing quote of
Expand Down
11 changes: 11 additions & 0 deletions src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6725,6 +6725,17 @@ void testClickHouseArrayJoin() throws Exception {
Assertions.assertFalse(joinInner.isLeft(), "Should not be a left join");
}

@Test
void testQuotedIdentifierContainingNewline() throws Exception {
// the newline is part of the identifier and must survive parse and deparse unchanged
String sql = "SELECT \"Planned/\nUnplanned\" FROM t";
TestUtils.assertSqlCanBeParsedAndDeparsed(sql, true);

PlainSelect select = (PlainSelect) CCJSqlParserUtil.parse(sql);
Column column = (Column) select.getSelectItem(0).getExpression();
Assertions.assertEquals("\"Planned/\nUnplanned\"", column.getColumnName());
}

@Test
void testSnowflakeArrayCastOnVariantPathInFlatten() throws Exception {
String sql = "CREATE OR REPLACE TABLE \"DB\".\"S\".\"T\" COPY GRANTS\n"
Expand Down
Loading