Execute LET statement: LET variable = expression [, variable = expression]
(
&self,
let_stmt: &crate::ast::LetStatement,
context: &mut ExecutionContext,
)
| 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( |
no test coverage detected