mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-23 17:05:36 +01:00
Enable only uuid by default, change tests back to account for this
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -1271,6 +1271,7 @@ dependencies = [
|
||||
"limbo_ext",
|
||||
"limbo_macros",
|
||||
"limbo_percentile",
|
||||
"limbo_regexp",
|
||||
"limbo_uuid",
|
||||
"log",
|
||||
"miette",
|
||||
|
||||
@@ -14,7 +14,7 @@ name = "limbo_core"
|
||||
path = "lib.rs"
|
||||
|
||||
[features]
|
||||
default = ["fs", "json", "uuid", "io_uring", "percentile"]
|
||||
default = ["fs", "json", "uuid", "io_uring"]
|
||||
fs = []
|
||||
json = [
|
||||
"dep:jsonb",
|
||||
@@ -24,6 +24,7 @@ json = [
|
||||
uuid = ["limbo_uuid/static"]
|
||||
io_uring = ["dep:io-uring", "rustix/io_uring"]
|
||||
percentile = ["limbo_percentile/static"]
|
||||
regexp = ["limbo_regexp/static"]
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
io-uring = { version = "0.6.1", optional = true }
|
||||
@@ -60,6 +61,7 @@ rand = "0.8.5"
|
||||
bumpalo = { version = "3.16.0", features = ["collections", "boxed"] }
|
||||
limbo_macros = { path = "../macros" }
|
||||
limbo_uuid = { path = "../extensions/uuid", optional = true, features = ["static"] }
|
||||
limbo_regexp = { path = "../extensions/regexp", optional = true, features = ["static"] }
|
||||
limbo_percentile = { path = "../extensions/percentile", optional = true, features = ["static"] }
|
||||
miette = "7.4.0"
|
||||
|
||||
|
||||
@@ -75,28 +75,19 @@ impl Database {
|
||||
}
|
||||
|
||||
pub fn register_builtins(&self) -> Result<(), String> {
|
||||
let ext_api = self.build_limbo_ext();
|
||||
#[cfg(feature = "uuid")]
|
||||
self.register_uuid()?;
|
||||
#[cfg(feature = "percentile")]
|
||||
self.register_percentile()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(feature = "uuid")]
|
||||
pub fn register_uuid(&self) -> Result<(), String> {
|
||||
let ext_api = Box::new(self.build_limbo_ext());
|
||||
if unsafe { !limbo_uuid::register_extension_static(&ext_api).is_ok() } {
|
||||
return Err("Failed to register uuid extension".to_string());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(feature = "percentile")]
|
||||
pub fn register_percentile(&self) -> Result<(), String> {
|
||||
let ext_api = self.build_limbo_ext();
|
||||
#[cfg(feature = "percentile")]
|
||||
if unsafe { !limbo_percentile::register_extension_static(&ext_api).is_ok() } {
|
||||
return Err("Failed to register percentile extension".to_string());
|
||||
}
|
||||
#[cfg(feature = "regexp")]
|
||||
if unsafe { !limbo_regexp::register_extension_static(&ext_api).is_ok() } {
|
||||
return Err("Failed to register regexp extension".to_string());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,11 +6,14 @@ edition.workspace = true
|
||||
license.workspace = true
|
||||
repository.workspace = true
|
||||
|
||||
[features]
|
||||
static = ["limbo_ext/static"]
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "lib"]
|
||||
|
||||
|
||||
[dependencies]
|
||||
limbo_ext = { path = "../core"}
|
||||
limbo_ext = { path = "../core", features = ["static"] }
|
||||
regex = "1.11.1"
|
||||
log = "0.4.20"
|
||||
|
||||
@@ -133,7 +133,6 @@ def assert_specific_time(result):
|
||||
|
||||
def test_uuid(pipe):
|
||||
specific_time = "01945ca0-3189-76c0-9a8f-caf310fc8b8e"
|
||||
|
||||
# these are built into the binary, so we just test they work
|
||||
run_test(
|
||||
pipe,
|
||||
@@ -210,7 +209,20 @@ def validate_percentile_disc(res):
|
||||
|
||||
|
||||
def test_aggregates(pipe):
|
||||
# also built-in
|
||||
extension_path = "./target/debug/liblimbo_percentile.so"
|
||||
# assert no function before extension loads
|
||||
run_test(
|
||||
pipe,
|
||||
"SELECT median(1);",
|
||||
returns_error,
|
||||
"median agg function returns null when ext not loaded",
|
||||
)
|
||||
run_test(
|
||||
pipe,
|
||||
f".load {extension_path}",
|
||||
returns_null,
|
||||
"load extension command works properly",
|
||||
)
|
||||
run_test(
|
||||
pipe,
|
||||
"select median(value) from numbers;",
|
||||
@@ -260,4 +272,3 @@ def main():
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user