@@ -1388,9 +1388,9 @@ impl<'a> Parser<'a> {
13881388 | Token::HexStringLiteral(_)
13891389 if w.value.starts_with('_') =>
13901390 {
1391- Ok(Expr::IntroducedString {
1392- introducer : w.value. clone(),
1393- value: self.parse_introduced_string_value ()?,
1391+ Ok(Expr::Prefixed {
1392+ prefix : w.clone().into_ident(w_span ),
1393+ value: self.parse_introduced_string_expr ()?.into() ,
13941394 })
13951395 }
13961396 // string introducer https://dev.mysql.com/doc/refman/8.0/en/charset-introducer.html
@@ -1399,9 +1399,9 @@ impl<'a> Parser<'a> {
13991399 | Token::HexStringLiteral(_)
14001400 if w.value.starts_with('_') =>
14011401 {
1402- Ok(Expr::IntroducedString {
1403- introducer : w.value. clone(),
1404- value: self.parse_introduced_string_value ()?,
1402+ Ok(Expr::Prefixed {
1403+ prefix : w.clone().into_ident(w_span ),
1404+ value: self.parse_introduced_string_expr ()?.into() ,
14051405 })
14061406 }
14071407 Token::Arrow if self.dialect.supports_lambda_functions() => {
@@ -9035,13 +9035,19 @@ impl<'a> Parser<'a> {
90359035 }
90369036 }
90379037
9038- fn parse_introduced_string_value (&mut self) -> Result<Value , ParserError> {
9038+ fn parse_introduced_string_expr (&mut self) -> Result<Expr , ParserError> {
90399039 let next_token = self.next_token();
90409040 let span = next_token.span;
90419041 match next_token.token {
9042- Token::SingleQuotedString(ref s) => Ok(Value::SingleQuotedString(s.to_string())),
9043- Token::DoubleQuotedString(ref s) => Ok(Value::DoubleQuotedString(s.to_string())),
9044- Token::HexStringLiteral(ref s) => Ok(Value::HexStringLiteral(s.to_string())),
9042+ Token::SingleQuotedString(ref s) => Ok(Expr::Value(
9043+ Value::SingleQuotedString(s.to_string()).with_span(span),
9044+ )),
9045+ Token::DoubleQuotedString(ref s) => Ok(Expr::Value(
9046+ Value::DoubleQuotedString(s.to_string()).with_span(span),
9047+ )),
9048+ Token::HexStringLiteral(ref s) => Ok(Expr::Value(
9049+ Value::HexStringLiteral(s.to_string()).with_span(span),
9050+ )),
90459051 unexpected => self.expected(
90469052 "a string value",
90479053 TokenWithSpan {
@@ -13968,6 +13974,13 @@ impl<'a> Parser<'a> {
1396813974
1396913975 /// Parse a comma-delimited list of projections after SELECT
1397013976 pub fn parse_select_item(&mut self) -> Result<SelectItem, ParserError> {
13977+ let prefix = self
13978+ .parse_one_of_keywords(
13979+ self.dialect
13980+ .get_reserved_keywords_for_select_item_operator(),
13981+ )
13982+ .map(|keyword| Ident::new(format!("{:?}", keyword)));
13983+
1397113984 match self.parse_wildcard_expr()? {
1397213985 Expr::QualifiedWildcard(prefix, token) => Ok(SelectItem::QualifiedWildcard(
1397313986 SelectItemQualifiedWildcardKind::ObjectName(prefix),
@@ -14012,8 +14025,11 @@ impl<'a> Parser<'a> {
1401214025 expr => self
1401314026 .maybe_parse_select_item_alias()
1401414027 .map(|alias| match alias {
14015- Some(alias) => SelectItem::ExprWithAlias { expr, alias },
14016- None => SelectItem::UnnamedExpr(expr),
14028+ Some(alias) => SelectItem::ExprWithAlias {
14029+ expr: maybe_prefixed_expr(expr, prefix),
14030+ alias,
14031+ },
14032+ None => SelectItem::UnnamedExpr(maybe_prefixed_expr(expr, prefix)),
1401714033 }),
1401814034 }
1401914035 }
@@ -15375,6 +15391,17 @@ impl<'a> Parser<'a> {
1537515391 }
1537615392}
1537715393
15394+ fn maybe_prefixed_expr(expr: Expr, prefix: Option<Ident>) -> Expr {
15395+ if let Some(prefix) = prefix {
15396+ Expr::Prefixed {
15397+ prefix,
15398+ value: Box::new(expr),
15399+ }
15400+ } else {
15401+ expr
15402+ }
15403+ }
15404+
1537815405impl Word {
1537915406 #[deprecated(since = "0.54.0", note = "please use `into_ident` instead")]
1538015407 pub fn to_ident(&self, span: Span) -> Ident {
0 commit comments