MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / parse_expr_string

Function parse_expr_string

nodedb-sql/src/lib.rs:47–63  ·  view source on GitHub ↗

Parse a standalone SQL expression string into an `SqlExpr`. Used by the DEFAULT expression evaluator to handle arbitrary expressions (e.g. `upper('x')`, `1 + 2`) that don't match the hard-coded keyword list.

(expr_text: &str)

Source from the content-addressed store, hash-verified

45/// Used by the DEFAULT expression evaluator to handle arbitrary expressions
46/// (e.g. `upper('x')`, `1 + 2`) that don't match the hard-coded keyword list.
47pub fn parse_expr_string(expr_text: &str) -> Result<SqlExpr> {
48 use sqlparser::dialect::GenericDialect;
49 use sqlparser::parser::Parser;
50
51 let dialect = GenericDialect {};
52 let ast_expr = Parser::new(&dialect)
53 .try_with_sql(expr_text)
54 .map_err(|e| SqlError::Parse {
55 detail: e.to_string(),
56 })?
57 .parse_expr()
58 .map_err(|e| SqlError::Parse {
59 detail: e.to_string(),
60 })?;
61
62 resolver::expr::convert_expr(&ast_expr)
63}
64
65use functions::registry::FunctionRegistry;
66use parser::array_stmt::{ArrayStatement, try_parse_array_statement};

Callers 2

partial_index_entailedFunction · 0.85
try_const_fold_defaultFunction · 0.85

Calls 3

convert_exprFunction · 0.85
parse_exprMethod · 0.80
to_stringMethod · 0.80

Tested by

no test coverage detected