From 790935b2b5b6240fb41a3842c413c0d0bb19da6d Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Thu, 27 Oct 2022 00:31:20 -0700 Subject: [PATCH] Ensure build succeeds without `uuid_unstable` build flag Closes #1403 --- lib/src/err/mod.rs | 7 +++++++ lib/src/fnc/rand.rs | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/lib/src/err/mod.rs b/lib/src/err/mod.rs index 0117bff3..cbdd586a 100644 --- a/lib/src/err/mod.rs +++ b/lib/src/err/mod.rs @@ -97,6 +97,13 @@ pub enum Error { message: String, }, + /// There was a problem running the specified function + #[error("There was a problem running the {name}() function. {message}")] + InvalidFunction { + name: String, + message: String, + }, + /// The wrong quantity or magnitude of arguments was given for the specified function #[error("Incorrect arguments for function {name}(). {message}")] InvalidArguments { diff --git a/lib/src/fnc/rand.rs b/lib/src/fnc/rand.rs index b28e222e..c7af2171 100644 --- a/lib/src/fnc/rand.rs +++ b/lib/src/fnc/rand.rs @@ -138,4 +138,11 @@ pub mod uuid { pub fn v7(_: ()) -> Result { Ok(Uuid::new_v7().into()) } + #[cfg(not(uuid_unstable))] + pub fn v7(_: ()) -> Result { + return Err(Error::InvalidFunction { + name: String::from("rand::uuid::v7"), + message: format!("This function is not enabled in this version of SurrealDB."), + }); + } }