Skip to main content

evaluate

Function evaluate 

Source
pub fn evaluate(
    input: &str,
    map: &HashMap<String, RuntimeValue>,
) -> Result<bool, EvalError>
Expand description

Evaluate a SQL boolean expression string with variable bindings.

§Arguments

  • input - SQL expression string to evaluate (must be boolean-valued)
  • map - Variable name to value bindings for substitution

§Returns

  • Ok(bool) - The evaluated boolean result
  • Err(EvalError) - Error during parsing, variable resolution, type checking, or evaluation

§Examples

use std::collections::HashMap;
use parser::{evaluate, RuntimeValue};

let mut map = HashMap::new();
map.insert("x".to_string(), RuntimeValue::Integer(42));

let result = evaluate("x > 10", &map).unwrap();
assert_eq!(result, true);