MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / evaluate_searched_case

Method evaluate_searched_case

graphlite/src/exec/executor.rs:4855–4875  ·  view source on GitHub ↗

Evaluate a searched CASE expression (CASE WHEN condition1 THEN result1 ...)

(
        &self,
        searched_case: &SearchedCaseExpression,
        context: &ExecutionContext,
    )

Source from the content-addressed store, hash-verified

4853
4854 /// Evaluate a searched CASE expression (CASE WHEN condition1 THEN result1 ...)
4855 fn evaluate_searched_case(
4856 &self,
4857 searched_case: &SearchedCaseExpression,
4858 context: &ExecutionContext,
4859 ) -> Result<Value, ExecutionError> {
4860 // Check each WHEN branch
4861 for when_branch in &searched_case.when_branches {
4862 let condition_value = self.evaluate_expression(&when_branch.condition, context)?;
4863
4864 // Check if condition is true
4865 if self.is_truthy(&condition_value)? {
4866 return self.evaluate_expression(&when_branch.then_expression, context);
4867 }
4868 }
4869
4870 // If no WHEN matched, evaluate ELSE or return NULL
4871 match &searched_case.else_expression {
4872 Some(else_expr) => self.evaluate_expression(else_expr, context),
4873 None => Ok(Value::Null),
4874 }
4875 }
4876
4877 /// Check if two values are equal for CASE comparison
4878 fn values_equal(&self, left: &Value, right: &Value) -> Result<bool, ExecutionError> {

Callers 1

Calls 2

is_truthyMethod · 0.80
evaluate_expressionMethod · 0.45

Tested by

no test coverage detected