use crate::errors::ExecutorError;
use crate::evaluator::functions::coercion::coerce_to_string;
pub(in crate::evaluator::functions) fn upper(
args: &[vibesql_types::SqlValue],
) -> Result<vibesql_types::SqlValue, ExecutorError> {
if args.len() != 1 {
return Err(ExecutorError::UnsupportedFeature(format!(
"UPPER requires exactly 1 argument, got {}",
args.len()
)));
}
match coerce_to_string(&args[0]) {
None => Ok(vibesql_types::SqlValue::Null),
Some(s) => Ok(vibesql_types::SqlValue::Varchar(arcstr::ArcStr::from(s.to_uppercase()))),
}
}
pub(in crate::evaluator::functions) fn lower(
args: &[vibesql_types::SqlValue],
) -> Result<vibesql_types::SqlValue, ExecutorError> {
if args.len() != 1 {
return Err(ExecutorError::UnsupportedFeature(format!(
"LOWER requires exactly 1 argument, got {}",
args.len()
)));
}
match coerce_to_string(&args[0]) {
None => Ok(vibesql_types::SqlValue::Null),
Some(s) => Ok(vibesql_types::SqlValue::Varchar(arcstr::ArcStr::from(s.to_lowercase()))),
}
}