diff --git a/Cargo.toml b/Cargo.toml index f9f7068c..94fe1429 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,9 +23,9 @@ members = ["libduckdb-sys"] [features] default = [] bundled = ["libduckdb-sys/bundled"] -httpfs = ["libduckdb-sys/httpfs"] -json = ["libduckdb-sys/json"] -parquet = ["libduckdb-sys/parquet"] +httpfs = ["libduckdb-sys/httpfs", "bundled"] +json = ["libduckdb-sys/json", "bundled"] +parquet = ["libduckdb-sys/parquet", "bundled"] extensions-full = ["httpfs", "json", "parquet"] buildtime_bindgen = ["libduckdb-sys/buildtime_bindgen"] diff --git a/src/lib.rs b/src/lib.rs index 4ad41cac..7fea192b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -524,6 +524,11 @@ impl Connection { path: self.path.clone(), }) } + + /// Returns the version of the DuckDB library + pub fn version(&self) -> Result<String> { + self.query_row("PRAGMA version", [], |row| row.get(0)) + } } impl fmt::Debug for Connection { @@ -1266,4 +1271,14 @@ mod test { assert_eq!(DatabaseName::Attached("abc").to_string(), "abc"); Ok(()) } + + #[cfg(feature = "bundled")] + #[test] + fn test_version() -> Result<()> { + let db = checked_memory_handle(); + const VERSION: &str = env!("CARGO_PKG_VERSION"); + let version = db.version()?; + assert_eq!(version, VERSION); + Ok(()) + } }