You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by lu...@apache.org on 2026/09/21 22:10:37 UTC
(datafusion-sqlparser-rs) 01/01: Generic: Disallow quoted identifiers in colon and at-sign placeholders
This is an automated email from the ASF dual-hosted git repository.
LucaCappelletti94 pushed a commit to branch fix-placeholder-quoted-ident
in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git
commit d432dcd070b48ddf220664f19695c6af2d732bad
Author: LucaCappelletti94 <ca...@gmail.com>
AuthorDate: Mon Sep 21 23:43:34 2026 +0200
Generic: Disallow quoted identifiers in colon and at-sign placeholders
---
src/parser/mod.rs | 2 +-
tests/sqlparser_common.rs | 42 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/src/parser/mod.rs b/src/parser/mod.rs
index 15f135ff..f2751bf0 100644
--- a/src/parser/mod.rs
+++ b/src/parser/mod.rs
@@ -12528,7 +12528,7 @@ impl<'a> Parser<'a> {
// without any whitespace in between
let next_token = self.next_token_no_skip().unwrap_or(&EOF_TOKEN).clone();
let ident = match next_token.token {
- Token::Word(w) => Ok(w.into_ident(next_token.span)),
+ Token::Word(w) if w.quote_style.is_none() => Ok(w.into_ident(next_token.span)),
Token::Number(w, false) => Ok(Ident::with_span(next_token.span, w)),
_ => self.expected("placeholder", next_token),
}?;
diff --git a/tests/sqlparser_common.rs b/tests/sqlparser_common.rs
index c4aa607d..0ae32e44 100644
--- a/tests/sqlparser_common.rs
+++ b/tests/sqlparser_common.rs
@@ -20080,3 +20080,45 @@ fn parse_unary_minus_never_renders_line_comment() {
all_dialects().verified_stmt("SELECT -1");
all_dialects().verified_stmt("SELECT -x");
}
+
+#[test]
+fn parse_placeholder_disallows_quoted_ident() {
+ let dialects = TestedDialects::new(vec![
+ Box::new(AnsiDialect {}),
+ Box::new(GenericDialect {}),
+ Box::new(SnowflakeDialect {}),
+ Box::new(SQLiteDialect {}),
+ ]);
+ // Valid placeholders roundtrip
+ dialects.verified_stmt("SELECT :x");
+
+ // Quoted identifiers are not valid placeholders
+ let err = dialects.parse_sql_statements("SELECT :`a`").unwrap_err();
+ assert_eq!(
+ ParserError::ParserError("Expected: placeholder, found: `a`".to_string()),
+ err
+ );
+ let err = dialects.parse_sql_statements("SELECT :\"a\"").unwrap_err();
+ assert_eq!(
+ ParserError::ParserError("Expected: placeholder, found: \"a\"".to_string()),
+ err
+ );
+ let err = dialects.parse_sql_statements("SELECT:` a` a").unwrap_err();
+ assert_eq!(
+ ParserError::ParserError("Expected: placeholder, found: ` a`".to_string()),
+ err
+ );
+
+ let ansi = TestedDialects::new(vec![Box::new(AnsiDialect {})]);
+ ansi.verified_stmt("SELECT @x");
+ let err = ansi.parse_sql_statements("SELECT @`a`").unwrap_err();
+ assert_eq!(
+ ParserError::ParserError("Expected: placeholder, found: `a`".to_string()),
+ err
+ );
+ let err = ansi.parse_sql_statements("SELECT @\"a\"").unwrap_err();
+ assert_eq!(
+ ParserError::ParserError("Expected: placeholder, found: \"a\"".to_string()),
+ err
+ );
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org