Cast a value to a target type
(
&self,
value: Value,
target_type: &crate::ast::TypeSpec,
)
| 4966 | |
| 4967 | /// Cast a value to a target type |
| 4968 | fn cast_value( |
| 4969 | &self, |
| 4970 | value: Value, |
| 4971 | target_type: &crate::ast::TypeSpec, |
| 4972 | ) -> Result<Value, ExecutionError> { |
| 4973 | use crate::ast::TypeSpec; |
| 4974 | |
| 4975 | match target_type { |
| 4976 | TypeSpec::Boolean => self.cast_to_boolean(value), |
| 4977 | TypeSpec::String { max_length } => self.cast_to_string(value, *max_length), |
| 4978 | TypeSpec::Integer => self.cast_to_integer(value), |
| 4979 | TypeSpec::BigInt => self.cast_to_bigint(value), |
| 4980 | TypeSpec::SmallInt => self.cast_to_smallint(value), |
| 4981 | TypeSpec::Float { .. } => self.cast_to_float(value), |
| 4982 | TypeSpec::Real => self.cast_to_real(value), |
| 4983 | TypeSpec::Double => self.cast_to_double(value), |
| 4984 | TypeSpec::Decimal { precision, scale } => { |
| 4985 | self.cast_to_decimal(value, *precision, *scale) |
| 4986 | } |
| 4987 | _ => Err(ExecutionError::RuntimeError(format!( |
| 4988 | "CAST to {:?} is not yet implemented", |
| 4989 | target_type |
| 4990 | ))), |
| 4991 | } |
| 4992 | } |
| 4993 | |
| 4994 | /// Cast value to BOOLEAN |
| 4995 | fn cast_to_boolean(&self, value: Value) -> Result<Value, ExecutionError> { |
no test coverage detected