Add safety comments and clean up extension types

This commit is contained in:
PThorpe92 2025-01-12 15:48:26 -05:00
parent 98eff6cf7a
commit 6e05258d36
No known key found for this signature in database
GPG key ID: 66DB3FBACBDD05CC
3 changed files with 28 additions and 24 deletions

View file

@ -73,7 +73,9 @@ declare_scalar_functions! {
Value::from_integer(unix as i64)
}
ValueType::Text => {
let text = TextValue::from_value(&args[0]).unwrap();
let Some(text) = (unsafe {TextValue::from_value(&args[0])}) else {
return Value::null();
};
let uuid = uuid::Uuid::parse_str(unsafe {text.as_str()}).unwrap();
let unix = uuid_to_unix(uuid.as_bytes());
Value::from_integer(unix as i64)
@ -106,16 +108,15 @@ declare_scalar_functions! {
log::debug!("uuid_blob was passed a non-text arg");
return Value::null();
}
if let Some(text) = TextValue::from_value(&args[0]) {
let Some(text) = (unsafe { TextValue::from_value(&args[0])}) else {
return Value::null();
};
match uuid::Uuid::parse_str(unsafe {text.as_str()}) {
Ok(uuid) => {
Value::from_blob(uuid.as_bytes().to_vec())
}
Err(_) => Value::null()
}
} else {
Value::null()
}
}
}