Add unhex(X) scalar function

This commit adds `unhex(X)` scalar function. Function with `unhex(X,Y)`
two arguments is not implemented yet.

Relates to issue #144
This commit is contained in:
Lauri Virtanen
2024-09-30 00:03:05 +03:00
parent b8dffbf7f9
commit adc6f9b6cd
5 changed files with 78 additions and 3 deletions

View File

@@ -77,6 +77,7 @@ pub enum ScalarFunc {
SqliteVersion,
UnixEpoch,
Hex,
Unhex,
}
impl Display for ScalarFunc {
@@ -112,6 +113,7 @@ impl Display for ScalarFunc {
ScalarFunc::SqliteVersion => "sqlite_version".to_string(),
ScalarFunc::UnixEpoch => "unixepoch".to_string(),
ScalarFunc::Hex => "hex".to_string(),
ScalarFunc::Unhex => "unhex".to_string(),
};
write!(f, "{}", str)
}
@@ -182,6 +184,7 @@ impl Func {
"json" => Ok(Func::Json(JsonFunc::Json)),
"unixepoch" => Ok(Func::Scalar(ScalarFunc::UnixEpoch)),
"hex" => Ok(Func::Scalar(ScalarFunc::Hex)),
"unhex" => Ok(Func::Scalar(ScalarFunc::Unhex)),
_ => Err(()),
}
}