Evaluate a unary operation
(
&self,
operator: &crate::ast::Operator,
operand: Value,
)
| 8362 | |
| 8363 | /// Evaluate a unary operation |
| 8364 | fn evaluate_unary_op( |
| 8365 | &self, |
| 8366 | operator: &crate::ast::Operator, |
| 8367 | operand: Value, |
| 8368 | ) -> Result<Value, ExecutionError> { |
| 8369 | match operator { |
| 8370 | crate::ast::Operator::Not => match operand { |
| 8371 | Value::Boolean(b) => Ok(Value::Boolean(!b)), |
| 8372 | _ => Err(ExecutionError::RuntimeError( |
| 8373 | "NOT operator requires boolean operand".to_string(), |
| 8374 | )), |
| 8375 | }, |
| 8376 | crate::ast::Operator::Minus => match operand { |
| 8377 | Value::Number(n) => Ok(Value::Number(-n)), |
| 8378 | _ => Err(ExecutionError::RuntimeError( |
| 8379 | "Unary minus requires numeric operand".to_string(), |
| 8380 | )), |
| 8381 | }, |
| 8382 | _ => Err(ExecutionError::RuntimeError(format!( |
| 8383 | "Unsupported unary operator: {:?}", |
| 8384 | operator |
| 8385 | ))), |
| 8386 | } |
| 8387 | } |
| 8388 | |
| 8389 | /// Check if a row contains any NULL values |
| 8390 | /// Used for SQL NULL semantics in set operations where NULL != NULL |
no outgoing calls
no test coverage detected