Evaluate a simple expression (literals and function calls) for INSERT/SET operations This is a lightweight evaluator for property expressions that don't require full row context
(
&self,
expr: &crate::ast::Expression,
)
| 290 | /// Evaluate a simple expression (literals and function calls) for INSERT/SET operations |
| 291 | /// This is a lightweight evaluator for property expressions that don't require full row context |
| 292 | pub fn evaluate_simple_expression( |
| 293 | &self, |
| 294 | expr: &crate::ast::Expression, |
| 295 | ) -> Result<Value, crate::exec::error::ExecutionError> { |
| 296 | use crate::ast::Expression; |
| 297 | use crate::exec::result::Row; |
| 298 | use crate::functions::FunctionContext; |
| 299 | |
| 300 | match expr { |
| 301 | Expression::Literal(literal) => { |
| 302 | // Convert literal to value |
| 303 | Ok(Self::literal_to_value(literal)) |
| 304 | } |
| 305 | |
| 306 | Expression::FunctionCall(func_call) => { |
| 307 | // Get the function registry |
| 308 | let function_registry = self.function_registry.as_ref().ok_or_else(|| { |
| 309 | crate::exec::error::ExecutionError::RuntimeError( |
| 310 | "Function registry not available in execution context".to_string(), |
| 311 | ) |
| 312 | })?; |
| 313 | |
| 314 | // Get the function from registry |
| 315 | let function = function_registry.get(&func_call.name).ok_or_else(|| { |
| 316 | crate::exec::error::ExecutionError::UnsupportedOperator(format!( |
| 317 | "Function not found: {}", |
| 318 | func_call.name |
| 319 | )) |
| 320 | })?; |
| 321 | |
| 322 | // Evaluate arguments recursively |
| 323 | let mut evaluated_args = Vec::new(); |
| 324 | for arg in &func_call.arguments { |
| 325 | let value = self.evaluate_simple_expression(arg)?; |
| 326 | evaluated_args.push(value); |
| 327 | } |
| 328 | |
| 329 | // Create function context with empty row set (no row context needed for simple expressions) |
| 330 | let temp_row = Row::new(); |
| 331 | let function_context = FunctionContext::with_storage( |
| 332 | vec![temp_row], |
| 333 | self.variables.clone(), |
| 334 | evaluated_args, |
| 335 | self.storage_manager.clone(), |
| 336 | self.current_graph.clone(), |
| 337 | self.get_current_graph_name(), |
| 338 | ); |
| 339 | |
| 340 | // Execute the function |
| 341 | function.execute(&function_context).map_err(|e| { |
| 342 | crate::exec::error::ExecutionError::UnsupportedOperator(format!( |
| 343 | "Function execution error: {}", |
| 344 | e |
| 345 | )) |
| 346 | }) |
| 347 | } |
| 348 | |
| 349 | Expression::Variable(var) => { |
no test coverage detected