@@ -1392,9 +1392,9 @@ impl<'a> Parser<'a> {
1392
1392
| Token::HexStringLiteral(_)
1393
1393
if w.value.starts_with('_') =>
1394
1394
{
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() ,
1398
1398
})
1399
1399
}
1400
1400
// string introducer https://dev.mysql.com/doc/refman/8.0/en/charset-introducer.html
@@ -1403,9 +1403,9 @@ impl<'a> Parser<'a> {
1403
1403
| Token::HexStringLiteral(_)
1404
1404
if w.value.starts_with('_') =>
1405
1405
{
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() ,
1409
1409
})
1410
1410
}
1411
1411
Token::Arrow if self.dialect.supports_lambda_functions() => {
@@ -8970,13 +8970,19 @@ impl<'a> Parser<'a> {
8970
8970
}
8971
8971
}
8972
8972
8973
- fn parse_introduced_string_value (&mut self) -> Result<Value , ParserError> {
8973
+ fn parse_introduced_string_expr (&mut self) -> Result<Expr , ParserError> {
8974
8974
let next_token = self.next_token();
8975
8975
let span = next_token.span;
8976
8976
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
+ )),
8980
8986
unexpected => self.expected(
8981
8987
"a string value",
8982
8988
TokenWithSpan {
@@ -13778,6 +13784,13 @@ impl<'a> Parser<'a> {
13778
13784
13779
13785
/// Parse a comma-delimited list of projections after SELECT
13780
13786
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
+
13781
13794
match self.parse_wildcard_expr()? {
13782
13795
Expr::QualifiedWildcard(prefix, token) => Ok(SelectItem::QualifiedWildcard(
13783
13796
SelectItemQualifiedWildcardKind::ObjectName(prefix),
@@ -13822,8 +13835,11 @@ impl<'a> Parser<'a> {
13822
13835
expr => self
13823
13836
.maybe_parse_select_item_alias()
13824
13837
.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)),
13827
13843
}),
13828
13844
}
13829
13845
}
@@ -15168,6 +15184,17 @@ impl<'a> Parser<'a> {
15168
15184
}
15169
15185
}
15170
15186
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
+
15171
15198
impl Word {
15172
15199
#[deprecated(since = "0.54.0", note = "please use `into_ident` instead")]
15173
15200
pub fn to_ident(&self, span: Span) -> Ident {
0 commit comments