iffyio commented on code in PR #2469:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/2469#discussion_r3966525366
##########
src/parser/mod.rs:
##########
@@ -20157,44 +20157,37 @@ impl<'a> Parser<'a> {
})
}
- fn parse_pragma_value(&mut self) -> Result<ValueWithSpan, ParserError> {
- let v = self.parse_value()?;
- match &v.value {
- Value::SingleQuotedString(_) => Ok(v),
- Value::DoubleQuotedString(_) => Ok(v),
- Value::Number(_, _) => Ok(v),
- Value::Placeholder(_) => Ok(v),
- _ => {
- self.prev_token();
- self.expected_ref("number or string or ? placeholder",
self.peek_token_ref())
- }
+ /// Parse a SQLite `pragma-value`: `signed-number | name | signed-literal`.
+ fn parse_pragma_value(&mut self) -> Result<Expr, ParserError> {
+ if matches!(self.peek_token_ref().token, Token::Plus | Token::Minus) {
+ let op = match self.next_token().token {
+ Token::Plus => UnaryOperator::Plus,
+ _ => UnaryOperator::Minus,
+ };
+ return Ok(Expr::UnaryOp {
+ op,
+ expr: Box::new(Expr::Value(self.parse_value()?)),
+ });
+ }
+ match self.maybe_parse(|parser| parser.parse_value())? {
+ Some(value) => Ok(Expr::Value(value)),
+ None => Ok(Expr::Identifier(self.parse_identifier()?)),
}
Review Comment:
hmm can this be replaced by a call to `parse_expr()`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]