@@ -1392,9 +1392,9 @@ impl<'a> Parser<'a> {
13921392 | Token::HexStringLiteral(_)
13931393 if w.value.starts_with('_') =>
13941394 {
1395- Ok(Expr::IntroducedString {
1396- introducer : w.value. clone(),
1397- value: self.parse_introduced_string_value ()?,
1395+ Ok(Expr::Prefixed {
1396+ prefix : w.clone().into_ident(w_span ),
1397+ value: self.parse_introduced_string_expr ()?.into() ,
13981398 })
13991399 }
14001400 // string introducer https://dev.mysql.com/doc/refman/8.0/en/charset-introducer.html
@@ -1403,9 +1403,9 @@ impl<'a> Parser<'a> {
14031403 | Token::HexStringLiteral(_)
14041404 if w.value.starts_with('_') =>
14051405 {
1406- Ok(Expr::IntroducedString {
1407- introducer : w.value. clone(),
1408- value: self.parse_introduced_string_value ()?,
1406+ Ok(Expr::Prefixed {
1407+ prefix : w.clone().into_ident(w_span ),
1408+ value: self.parse_introduced_string_expr ()?.into() ,
14091409 })
14101410 }
14111411 Token::Arrow if self.dialect.supports_lambda_functions() => {
@@ -8970,13 +8970,19 @@ impl<'a> Parser<'a> {
89708970 }
89718971 }
89728972
8973- fn parse_introduced_string_value (&mut self) -> Result<Value , ParserError> {
8973+ fn parse_introduced_string_expr (&mut self) -> Result<Expr , ParserError> {
89748974 let next_token = self.next_token();
89758975 let span = next_token.span;
89768976 match next_token.token {
8977- Token::SingleQuotedString(ref s) => Ok(Value::SingleQuotedString(s.to_string())),
8978- Token::DoubleQuotedString(ref s) => Ok(Value::DoubleQuotedString(s.to_string())),
8979- Token::HexStringLiteral(ref s) => Ok(Value::HexStringLiteral(s.to_string())),
8977+ Token::SingleQuotedString(ref s) => Ok(Expr::Value(
8978+ Value::SingleQuotedString(s.to_string()).with_span(span),
8979+ )),
8980+ Token::DoubleQuotedString(ref s) => Ok(Expr::Value(
8981+ Value::DoubleQuotedString(s.to_string()).with_span(span),
8982+ )),
8983+ Token::HexStringLiteral(ref s) => Ok(Expr::Value(
8984+ Value::HexStringLiteral(s.to_string()).with_span(span),
8985+ )),
89808986 unexpected => self.expected(
89818987 "a string value",
89828988 TokenWithSpan {
@@ -13778,6 +13784,13 @@ impl<'a> Parser<'a> {
1377813784
1377913785 /// Parse a comma-delimited list of projections after SELECT
1378013786 pub fn parse_select_item(&mut self) -> Result<SelectItem, ParserError> {
13787+ let prefix = self
13788+ .parse_one_of_keywords(
13789+ self.dialect
13790+ .get_reserved_keywords_for_select_item_operator(),
13791+ )
13792+ .map(|keyword| Ident::new(format!("{:?}", keyword)));
13793+
1378113794 match self.parse_wildcard_expr()? {
1378213795 Expr::QualifiedWildcard(prefix, token) => Ok(SelectItem::QualifiedWildcard(
1378313796 SelectItemQualifiedWildcardKind::ObjectName(prefix),
@@ -13822,8 +13835,11 @@ impl<'a> Parser<'a> {
1382213835 expr => self
1382313836 .maybe_parse_select_item_alias()
1382413837 .map(|alias| match alias {
13825- Some(alias) => SelectItem::ExprWithAlias { expr, alias },
13826- None => SelectItem::UnnamedExpr(expr),
13838+ Some(alias) => SelectItem::ExprWithAlias {
13839+ expr: prefixed_expr(expr, prefix),
13840+ alias,
13841+ },
13842+ None => SelectItem::UnnamedExpr(prefixed_expr(expr, prefix)),
1382713843 }),
1382813844 }
1382913845 }
@@ -15168,6 +15184,17 @@ impl<'a> Parser<'a> {
1516815184 }
1516915185}
1517015186
15187+ fn prefixed_expr(expr: Expr, prefix: Option<Ident>) -> Expr {
15188+ if let Some(prefix) = prefix {
15189+ Expr::Prefixed {
15190+ prefix,
15191+ value: Box::new(expr),
15192+ }
15193+ } else {
15194+ expr
15195+ }
15196+ }
15197+
1517115198impl Word {
1517215199 #[deprecated(since = "0.54.0", note = "please use `into_ident` instead")]
1517315200 pub fn to_ident(&self, span: Span) -> Ident {
0 commit comments