(
op: UnaryOperator,
expr: Expr,
unsupported: fn(Expr) -> SqlUnsupported,
)
| 272 | } |
| 273 | |
| 274 | fn parse_signed_literal_expr( |
| 275 | op: UnaryOperator, |
| 276 | expr: Expr, |
| 277 | unsupported: fn(Expr) -> SqlUnsupported, |
| 278 | ) -> SqlParseResult<SqlLiteral> { |
| 279 | match expr { |
| 280 | Expr::Value(Value::Number(n, _)) => { |
| 281 | let sign = match op { |
| 282 | UnaryOperator::Plus => "+", |
| 283 | UnaryOperator::Minus => "-", |
| 284 | _ => unreachable!("caller only passes unary plus/minus"), |
| 285 | }; |
| 286 | Ok(SqlLiteral::Num(format!("{sign}{n}").into_boxed_str())) |
| 287 | } |
| 288 | expr => Err(unsupported(Expr::UnaryOp { |
| 289 | op, |
| 290 | expr: Box::new(expr), |
| 291 | }) |
| 292 | .into()), |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | /// Parse a literal expression. |
| 297 | pub(crate) fn parse_literal_expr(expr: Expr, unsupported: fn(Expr) -> SqlUnsupported) -> SqlParseResult<SqlLiteral> { |
no test coverage detected
searching dependent graphs…