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

Method execute_let_statement

graphlite/src/exec/executor.rs:7117–7147  ·  view source on GitHub ↗

Execute LET statement: LET variable = expression [, variable = expression]

(
        &self,
        let_stmt: &crate::ast::LetStatement,
        context: &mut ExecutionContext,
    )

Source from the content-addressed store, hash-verified

7115
7116 /// Execute LET statement: LET variable = expression [, variable = expression]*
7117 fn execute_let_statement(
7118 &self,
7119 let_stmt: &crate::ast::LetStatement,
7120 context: &mut ExecutionContext,
7121 ) -> Result<QueryResult, ExecutionError> {
7122 // LET statements create variables in the context for use in subsequent queries
7123
7124 let mut result = QueryResult::new();
7125 let mut row = Row::new();
7126
7127 // Process each variable definition
7128 for var_def in &let_stmt.variable_definitions {
7129 // Evaluate the expression using the passed context
7130 let value = self.evaluate_expression(&var_def.expression, context)?;
7131
7132 // Add the variable to the context for use in subsequent statements
7133 context
7134 .variables
7135 .insert(var_def.variable_name.clone(), value.clone());
7136
7137 // Add the variable to the result
7138 result.variables.push(var_def.variable_name.clone());
7139 row.add_value(var_def.variable_name.clone(), value.clone());
7140 row.positional_values.push(value);
7141 }
7142
7143 // Add the single row with all variables
7144 result.rows.push(row);
7145
7146 Ok(result)
7147 }
7148
7149 /// Execute FOR statement: FOR [alias:] variable IN expression
7150 fn execute_for_statement(

Callers 3

execute_statementMethod · 0.80

Calls 4

cloneMethod · 0.80
add_valueMethod · 0.80
evaluate_expressionMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected