MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / parse_signed_literal_expr

Function parse_signed_literal_expr

crates/sql-parser/src/parser/mod.rs:274–294  ·  view source on GitHub ↗
(
    op: UnaryOperator,
    expr: Expr,
    unsupported: fn(Expr) -> SqlUnsupported,
)

Source from the content-addressed store, hash-verified

272}
273
274fn 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.
297pub(crate) fn parse_literal_expr(expr: Expr, unsupported: fn(Expr) -> SqlUnsupported) -> SqlParseResult<SqlLiteral> {

Callers 2

parse_exprFunction · 0.85
parse_literal_exprFunction · 0.85

Calls 4

unsupportedFunction · 0.70
OkFunction · 0.50
ErrFunction · 0.50
newFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…