Make julid_string() return a new stringy Julid.
This commit is contained in:
parent
34f85a95a0
commit
f2ade6d85e
3 changed files with 9 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "julid-rs"
|
||||
version = "1.6.18033"
|
||||
version = "1.6.180339"
|
||||
authors = ["Joe Ardent <code@ardent.nebcorp.com>"]
|
||||
edition = "2021"
|
||||
keywords = ["ulid", "library", "sqlite", "extension", "julid"]
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
1.618033
|
||||
1.6180339
|
||||
|
|
12
src/lib.rs
12
src/lib.rs
|
@ -52,7 +52,7 @@ pub mod sqlite_plugin {
|
|||
define_scalar_function(db, "julid_seconds", 1, julid_seconds, flags)?;
|
||||
define_scalar_function(db, "julid_counter", 1, julid_counter, flags)?;
|
||||
define_scalar_function(db, "julid_sortable", 1, julid_sortable, flags)?;
|
||||
define_scalar_function(db, "julid_string", 1, julid_string, flags)?;
|
||||
define_scalar_function(db, "julid_string", -1, julid_string, FunctionFlags::UTF8)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -76,10 +76,14 @@ pub mod sqlite_plugin {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Return the human-readable base32 Crockford encoding of this Julid.
|
||||
/// Return the human-readable base32 Crockford encoding of the given Julid,
|
||||
/// or create a new one if no arguments.
|
||||
///
|
||||
/// ```text
|
||||
/// sqlite> select julid_string(julid_new());
|
||||
/// 01H6C7D9CT00009TF3EXXJHX4Y
|
||||
/// sqlite> select julid_string();
|
||||
/// 01HJSHZ0PN000EKP3H94R6TPWH
|
||||
/// ```
|
||||
pub fn julid_string(context: *mut sqlite3_context, id: &[*mut sqlite3_value]) -> Result<()> {
|
||||
if let Some(value) = id.get(0) {
|
||||
|
@ -90,9 +94,7 @@ pub mod sqlite_plugin {
|
|||
let id: Julid = bytes.into();
|
||||
api::result_text(context, id.as_string())?;
|
||||
} else {
|
||||
return Err(sqlite_loadable::Error::new_message(
|
||||
"Could not convert empty Julid to string",
|
||||
));
|
||||
api::result_text(context, Julid::new().as_string())?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in a new issue