diff --git a/Cargo.toml b/Cargo.toml index c34f72b..b55980e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "julid-rs" -version = "1.6.18033" +version = "1.6.180339" authors = ["Joe Ardent "] edition = "2021" keywords = ["ulid", "library", "sqlite", "extension", "julid"] diff --git a/VERSION b/VERSION index f8903b6..fb9e103 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.618033 +1.6180339 diff --git a/src/lib.rs b/src/lib.rs index d89766c..ef6ff1d 100644 --- a/src/lib.rs +++ b/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(())