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

Method cast_to_integer

graphlite/src/exec/executor.rs:5062–5079  ·  view source on GitHub ↗

Cast value to INTEGER

(&self, value: Value)

Source from the content-addressed store, hash-verified

5060
5061 /// Cast value to INTEGER
5062 fn cast_to_integer(&self, value: Value) -> Result<Value, ExecutionError> {
5063 match value {
5064 Value::Number(n) => Ok(Value::Number(n.trunc())),
5065 Value::String(s) => match s.parse::<f64>() {
5066 Ok(n) => Ok(Value::Number(n.trunc())),
5067 Err(_) => Err(ExecutionError::RuntimeError(format!(
5068 "Cannot cast '{}' to INTEGER",
5069 s
5070 ))),
5071 },
5072 Value::Boolean(b) => Ok(Value::Number(if b { 1.0 } else { 0.0 })),
5073 Value::Null => Ok(Value::Null),
5074 _ => Err(ExecutionError::RuntimeError(format!(
5075 "Cannot cast {:?} to INTEGER",
5076 value.type_name()
5077 ))),
5078 }
5079 }
5080
5081 /// Cast value to BIGINT
5082 fn cast_to_bigint(&self, value: Value) -> Result<Value, ExecutionError> {

Callers 3

cast_valueMethod · 0.80
cast_to_bigintMethod · 0.80
cast_to_smallintMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected