Skip to content

Commit 71dc966

Browse files
Fix quoted identifier regression edge-case with "from" in SELECT (#1346)
1 parent 028ada8 commit 71dc966

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/parser/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10331,7 +10331,7 @@ impl<'a> Parser<'a> {
1033110331
Expr::Wildcard => Ok(SelectItem::Wildcard(
1033210332
self.parse_wildcard_additional_options()?,
1033310333
)),
10334-
Expr::Identifier(v) if v.value.to_lowercase() == "from" => {
10334+
Expr::Identifier(v) if v.value.to_lowercase() == "from" && v.quote_style.is_none() => {
1033510335
parser_err!(
1033610336
format!("Expected an expression, found: {}", v),
1033710337
self.peek_token().location

tests/sqlparser_common.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9005,7 +9005,7 @@ fn parse_non_latin_identifiers() {
90059005

90069006
#[test]
90079007
fn parse_trailing_comma() {
9008-
// At the moment, Duck DB is the only dialect that allows
9008+
// At the moment, DuckDB is the only dialect that allows
90099009
// trailing commas anywhere in the query
90109010
let trailing_commas = TestedDialects {
90119011
dialects: vec![Box::new(DuckDbDialect {})],
@@ -9038,11 +9038,16 @@ fn parse_trailing_comma() {
90389038
);
90399039

90409040
trailing_commas.verified_stmt("SELECT album_id, name FROM track");
9041-
90429041
trailing_commas.verified_stmt("SELECT * FROM track ORDER BY milliseconds");
9043-
90449042
trailing_commas.verified_stmt("SELECT DISTINCT ON (album_id) name FROM track");
90459043

9044+
// check quoted "from" identifier edge-case
9045+
trailing_commas.one_statement_parses_to(
9046+
r#"SELECT "from", FROM "from""#,
9047+
r#"SELECT "from" FROM "from""#,
9048+
);
9049+
trailing_commas.verified_stmt(r#"SELECT "from" FROM "from""#);
9050+
90469051
// doesn't allow any trailing commas
90479052
let trailing_commas = TestedDialects {
90489053
dialects: vec![Box::new(GenericDialect {})],

0 commit comments

Comments
 (0)