Support for postgres String Constants with Unicode Escapes (#1355)

This commit is contained in:
Ophir LOJKINE 2024-07-29 23:18:16 +02:00 committed by GitHub
parent c3ba2f33c6
commit bc15f7b4ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 180 additions and 0 deletions

View file

@ -1191,6 +1191,10 @@ impl<'a> Parser<'a> {
self.prev_token();
Ok(Expr::Value(self.parse_value()?))
}
Token::UnicodeStringLiteral(_) => {
self.prev_token();
Ok(Expr::Value(self.parse_value()?))
}
Token::Number(_, _)
| Token::SingleQuotedString(_)
| Token::DoubleQuotedString(_)
@ -1868,6 +1872,7 @@ impl<'a> Parser<'a> {
}
Token::SingleQuotedString(_)
| Token::EscapedStringLiteral(_)
| Token::UnicodeStringLiteral(_)
| Token::NationalStringLiteral(_)
| Token::HexStringLiteral(_) => Some(Box::new(self.parse_expr()?)),
_ => self.expected(
@ -6965,6 +6970,7 @@ impl<'a> Parser<'a> {
}
Token::NationalStringLiteral(ref s) => Ok(Value::NationalStringLiteral(s.to_string())),
Token::EscapedStringLiteral(ref s) => Ok(Value::EscapedStringLiteral(s.to_string())),
Token::UnicodeStringLiteral(ref s) => Ok(Value::UnicodeStringLiteral(s.to_string())),
Token::HexStringLiteral(ref s) => Ok(Value::HexStringLiteral(s.to_string())),
Token::Placeholder(ref s) => Ok(Value::Placeholder(s.to_string())),
tok @ Token::Colon | tok @ Token::AtSign => {
@ -7056,6 +7062,7 @@ impl<'a> Parser<'a> {
Token::EscapedStringLiteral(s) if dialect_of!(self is PostgreSqlDialect | GenericDialect) => {
Ok(s)
}
Token::UnicodeStringLiteral(s) => Ok(s),
_ => self.expected("literal string", next_token),
}
}