@@ -1388,9 +1388,9 @@ impl<'a> Parser<'a> {
1388
1388
| Token::HexStringLiteral(_)
1389
1389
if w.value.starts_with('_') =>
1390
1390
{
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() ,
1394
1394
})
1395
1395
}
1396
1396
// string introducer https://dev.mysql.com/doc/refman/8.0/en/charset-introducer.html
@@ -1399,9 +1399,9 @@ impl<'a> Parser<'a> {
1399
1399
| Token::HexStringLiteral(_)
1400
1400
if w.value.starts_with('_') =>
1401
1401
{
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() ,
1405
1405
})
1406
1406
}
1407
1407
Token::Arrow if self.dialect.supports_lambda_functions() => {
@@ -9035,13 +9035,19 @@ impl<'a> Parser<'a> {
9035
9035
}
9036
9036
}
9037
9037
9038
- fn parse_introduced_string_value (&mut self) -> Result<Value , ParserError> {
9038
+ fn parse_introduced_string_expr (&mut self) -> Result<Expr , ParserError> {
9039
9039
let next_token = self.next_token();
9040
9040
let span = next_token.span;
9041
9041
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
+ )),
9045
9051
unexpected => self.expected(
9046
9052
"a string value",
9047
9053
TokenWithSpan {
@@ -13968,6 +13974,13 @@ impl<'a> Parser<'a> {
13968
13974
13969
13975
/// Parse a comma-delimited list of projections after SELECT
13970
13976
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
+
13971
13984
match self.parse_wildcard_expr()? {
13972
13985
Expr::QualifiedWildcard(prefix, token) => Ok(SelectItem::QualifiedWildcard(
13973
13986
SelectItemQualifiedWildcardKind::ObjectName(prefix),
@@ -14012,8 +14025,11 @@ impl<'a> Parser<'a> {
14012
14025
expr => self
14013
14026
.maybe_parse_select_item_alias()
14014
14027
.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)),
14017
14033
}),
14018
14034
}
14019
14035
}
@@ -15375,6 +15391,17 @@ impl<'a> Parser<'a> {
15375
15391
}
15376
15392
}
15377
15393
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
+
15378
15405
impl Word {
15379
15406
#[deprecated(since = "0.54.0", note = "please use `into_ident` instead")]
15380
15407
pub fn to_ident(&self, span: Span) -> Ident {
0 commit comments