Evaluate a WHERE expression on a single row
(
&self,
where_clause: &crate::ast::WhereClause,
row: &Row,
context: &ExecutionContext,
)
| 1607 | |
| 1608 | /// Evaluate a WHERE expression on a single row |
| 1609 | fn evaluate_where_expression_on_row( |
| 1610 | &self, |
| 1611 | where_clause: &crate::ast::WhereClause, |
| 1612 | row: &Row, |
| 1613 | context: &ExecutionContext, |
| 1614 | ) -> Result<bool, ExecutionError> { |
| 1615 | // Create a temporary context that includes the current row data |
| 1616 | let mut temp_context = context.clone(); |
| 1617 | |
| 1618 | // Add row variables to the context |
| 1619 | for (key, value) in &row.values { |
| 1620 | temp_context.variables.insert(key.clone(), value.clone()); |
| 1621 | } |
| 1622 | |
| 1623 | // Use the regular expression evaluation which handles binary expressions |
| 1624 | let result = self.evaluate_expression(&where_clause.condition, &temp_context)?; |
| 1625 | match result { |
| 1626 | crate::storage::Value::Boolean(b) => Ok(b), |
| 1627 | crate::storage::Value::Null => Ok(false), |
| 1628 | crate::storage::Value::Number(n) => Ok(n != 0.0), |
| 1629 | _ => Ok(true), // Non-null, non-false values are truthy |
| 1630 | } |
| 1631 | } |
| 1632 | |
| 1633 | /// Convert Vec<Row> to the format expected by WithClauseProcessor |
| 1634 | fn convert_rows_to_processor_format( |
no test coverage detected