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

Method cast_value

graphlite/src/exec/executor.rs:4968–4992  ·  view source on GitHub ↗

Cast a value to a target type

(
        &self,
        value: Value,
        target_type: &crate::ast::TypeSpec,
    )

Source from the content-addressed store, hash-verified

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> {

Callers 1

Calls 9

cast_to_booleanMethod · 0.80
cast_to_stringMethod · 0.80
cast_to_integerMethod · 0.80
cast_to_bigintMethod · 0.80
cast_to_smallintMethod · 0.80
cast_to_floatMethod · 0.80
cast_to_realMethod · 0.80
cast_to_doubleMethod · 0.80
cast_to_decimalMethod · 0.80

Tested by

no test coverage detected