diff --git a/.github/workflows/rust.yaml b/.github/workflows/rust.yaml index 35358cd9..203c5362 100644 --- a/.github/workflows/rust.yaml +++ b/.github/workflows/rust.yaml @@ -65,6 +65,7 @@ jobs: # Intentionally omit time feature until we're on time 0.3, at which # point it should be added to `bundled-full`. args: '--features "buildtime_bindgen" --features "modern-full" --avoid-cfg-tarpaulin' # TODO restore to normal (https://github.com/xd009642/tarpaulin/issues/756#issuecomment-838769320) + version: 0.22.0 env: DUCKDB_LIB_DIR: ${{ github.workspace }}/libduckdb DUCKDB_INCLUDE_DIR: ${{ github.workspace }}/libduckdb diff --git a/Cargo.toml b/Cargo.toml index a94b01d4..65072b48 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,7 +47,7 @@ memchr = "2.3" uuid = { version = "1.0", optional = true } smallvec = "1.6.1" cast = { version = "0.3", features = ["std"] } -arrow = { version = "31", default-features = false, features = ["prettyprint", "ffi"] } +arrow = { version = "32", default-features = false, features = ["prettyprint", "ffi"] } rust_decimal = "1.14" strum = { version = "0.24", features = ["derive"] } r2d2 = { version = "0.8.9", optional = true } diff --git a/libduckdb-sys/Cargo.toml b/libduckdb-sys/Cargo.toml index f9b84a8d..94d19169 100644 --- a/libduckdb-sys/Cargo.toml +++ b/libduckdb-sys/Cargo.toml @@ -28,4 +28,4 @@ cc = { version = "1.0", features = ["parallel"], optional = true } vcpkg = { version = "0.2", optional = true } [dev-dependencies] -arrow = { version = "31", default-features = false, features = ["ffi"] } \ No newline at end of file +arrow = { version = "32", default-features = false, features = ["ffi"] } \ No newline at end of file diff --git a/libduckdb-sys/build.rs b/libduckdb-sys/build.rs index bc377b7f..81a47a2e 100644 --- a/libduckdb-sys/build.rs +++ b/libduckdb-sys/build.rs @@ -51,7 +51,7 @@ mod build_bundled { #[cfg(feature = "buildtime_bindgen")] { use super::{bindings, HeaderLocation}; - let header = HeaderLocation::FromPath(format!("{}/duckdb.h", lib_name)); + let header = HeaderLocation::FromPath(format!("{lib_name}/duckdb.h")); bindings::write_to_out_dir(header, out_path); } #[cfg(not(feature = "buildtime_bindgen"))] @@ -60,10 +60,10 @@ mod build_bundled { fs::copy(format!("{}/bindgen_bundled_version.rs", lib_name), out_path) .expect("Could not copy bindings to output directory"); } - println!("cargo:rerun-if-changed={}/duckdb.hpp", lib_name); - println!("cargo:rerun-if-changed={}/duckdb.cpp", lib_name); + println!("cargo:rerun-if-changed={lib_name}/duckdb.hpp"); + println!("cargo:rerun-if-changed={lib_name}/duckdb.cpp"); let mut cfg = cc::Build::new(); - cfg.file(format!("{}/duckdb.cpp", lib_name)) + cfg.file(format!("{lib_name}/duckdb.cpp")) .cpp(true) .flag_if_supported("-std=c++11") .flag_if_supported("-stdlib=libc++") @@ -77,7 +77,7 @@ mod build_bundled { cfg.compile(lib_name); - println!("cargo:lib_dir={}", out_dir); + println!("cargo:lib_dir={out_dir}"); } } @@ -100,7 +100,7 @@ impl From for String { match header { HeaderLocation::FromEnvironment => { let prefix = env_prefix(); - let mut header = env::var(format!("{}_INCLUDE_DIR", prefix)) + let mut header = env::var(format!("{prefix}_INCLUDE_DIR")) .unwrap_or_else(|_| env::var(format!("{}_LIB_DIR", env_prefix())).unwrap()); header.push_str("/duckdb.h"); header @@ -162,23 +162,23 @@ mod build_linked { // `links=` value in our Cargo.toml) to get this value. This might be // useful if you need to ensure whatever crypto library sqlcipher relies // on is available, for example. - println!("cargo:link-target={}", link_lib); + println!("cargo:link-target={link_lib}"); if win_target() && cfg!(feature = "winduckdb") { - println!("cargo:rustc-link-lib=dylib={}", link_lib); + println!("cargo:rustc-link-lib=dylib={link_lib}"); return HeaderLocation::Wrapper; } // Allow users to specify where to find DuckDB. if let Ok(dir) = env::var(format!("{}_LIB_DIR", env_prefix())) { - println!("cargo:rustc-env=LD_LIBRARY_PATH={}", dir); + println!("cargo:rustc-env=LD_LIBRARY_PATH={dir}"); // Try to use pkg-config to determine link commands let pkgconfig_path = Path::new(&dir).join("pkgconfig"); env::set_var("PKG_CONFIG_PATH", pkgconfig_path); if pkg_config::Config::new().probe(link_lib).is_err() { // Otherwise just emit the bare minimum link commands. println!("cargo:rustc-link-lib={}={}", find_link_mode(), link_lib); - println!("cargo:rustc-link-search={}", dir); + println!("cargo:rustc-link-search={dir}"); } return HeaderLocation::FromEnvironment; } @@ -241,7 +241,7 @@ mod bindings { .parse_callbacks(Box::new(bindgen::CargoCallbacks)) .rustfmt_bindings(true) .generate() - .unwrap_or_else(|_| panic!("could not run bindgen on header {}", header)) + .unwrap_or_else(|_| panic!("could not run bindgen on header {header}")) .write(Box::new(&mut output)) .expect("could not write output of bindgen"); let output = String::from_utf8(output).expect("bindgen output was not UTF-8?!"); @@ -250,9 +250,9 @@ mod bindings { .truncate(true) .create(true) .open(out_path) - .unwrap_or_else(|_| panic!("Could not write to {:?}", out_path)); + .unwrap_or_else(|_| panic!("Could not write to {out_path:?}")); file.write_all(output.as_bytes()) - .unwrap_or_else(|_| panic!("Could not write to {:?}", out_path)); + .unwrap_or_else(|_| panic!("Could not write to {out_path:?}")); } } diff --git a/libduckdb-sys/src/lib.rs b/libduckdb-sys/src/lib.rs index c097be99..99de767c 100644 --- a/libduckdb-sys/src/lib.rs +++ b/libduckdb-sys/src/lib.rs @@ -42,7 +42,7 @@ mod tests { for row_idx in 0..duckdb_row_count(&mut result) { for col_idx in 0..duckdb_column_count(&mut result) { let val = duckdb_value_int32(&mut result, col_idx, row_idx); - print!("{} ", val); + print!("{val} "); } println!(); } diff --git a/src/column.rs b/src/column.rs index 2cc7803b..b7ab88ae 100644 --- a/src/column.rs +++ b/src/column.rs @@ -184,7 +184,7 @@ mod test { assert_eq!(ty, Type::Int); } e => { - panic!("Unexpected error type: {:?}", e); + panic!("Unexpected error type: {e:?}"); } } match row.get::<_, String>("y").unwrap_err() { @@ -194,7 +194,7 @@ mod test { assert_eq!(ty, Type::Null); } e => { - panic!("Unexpected error type: {:?}", e); + panic!("Unexpected error type: {e:?}"); } } Ok(()) diff --git a/src/config.rs b/src/config.rs index df9cd7e9..e5368714 100644 --- a/src/config.rs +++ b/src/config.rs @@ -117,7 +117,7 @@ impl Config { if state != ffi::DuckDBSuccess { return Err(Error::DuckDBFailure( ffi::Error::new(state), - Some(format!("set {}:{} error", key, value)), + Some(format!("set {key}:{value} error")), )); } Ok(()) diff --git a/src/error.rs b/src/error.rs index af633bbd..f66887d3 100644 --- a/src/error.rs +++ b/src/error.rs @@ -145,40 +145,38 @@ impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Error::DuckDBFailure(ref err, None) => err.fmt(f), - Error::DuckDBFailure(_, Some(ref s)) => write!(f, "{}", s), + Error::DuckDBFailure(_, Some(ref s)) => write!(f, "{s}"), Error::FromSqlConversionFailure(i, ref t, ref err) => { if i != UNKNOWN_COLUMN { - write!(f, "Conversion error from type {} at index: {}, {}", t, i, err) + write!(f, "Conversion error from type {t} at index: {i}, {err}") } else { err.fmt(f) } } Error::IntegralValueOutOfRange(col, val) => { if col != UNKNOWN_COLUMN { - write!(f, "Integer {} out of range at index {}", val, col) + write!(f, "Integer {val} out of range at index {col}") } else { - write!(f, "Integer {} out of range", val) + write!(f, "Integer {val} out of range") } } Error::Utf8Error(ref err) => err.fmt(f), Error::NulError(ref err) => err.fmt(f), - Error::InvalidParameterName(ref name) => write!(f, "Invalid parameter name: {}", name), + Error::InvalidParameterName(ref name) => write!(f, "Invalid parameter name: {name}"), Error::InvalidPath(ref p) => write!(f, "Invalid path: {}", p.to_string_lossy()), Error::ExecuteReturnedResults => { write!(f, "Execute returned results - did you mean to call query?") } Error::QueryReturnedNoRows => write!(f, "Query returned no rows"), - Error::InvalidColumnIndex(i) => write!(f, "Invalid column index: {}", i), - Error::InvalidColumnName(ref name) => write!(f, "Invalid column name: {}", name), + Error::InvalidColumnIndex(i) => write!(f, "Invalid column index: {i}"), + Error::InvalidColumnName(ref name) => write!(f, "Invalid column name: {name}"), Error::InvalidColumnType(i, ref name, ref t) => { - write!(f, "Invalid column type {} at index: {}, name: {}", t, i, name) + write!(f, "Invalid column type {t} at index: {i}, name: {name}") } - Error::InvalidParameterCount(i1, n1) => write!( - f, - "Wrong number of parameters passed to query. Got {}, needed {}", - i1, n1 - ), - Error::StatementChangedRows(i) => write!(f, "Query changed {} rows", i), + Error::InvalidParameterCount(i1, n1) => { + write!(f, "Wrong number of parameters passed to query. Got {i1}, needed {n1}") + } + Error::StatementChangedRows(i) => write!(f, "Query changed {i} rows"), Error::ToSqlConversionFailure(ref err) => err.fmt(f), Error::InvalidQuery => write!(f, "Query is not read-only"), Error::MultipleStatement => write!(f, "Multiple statements provided"), diff --git a/src/inner_connection.rs b/src/inner_connection.rs index 09420762..27ddca6a 100644 --- a/src/inner_connection.rs +++ b/src/inner_connection.rs @@ -117,9 +117,9 @@ impl Drop for InnerConnection { use std::thread::panicking; if let Err(e) = self.close() { if panicking() { - eprintln!("Error while closing DuckDB connection: {:?}", e); + eprintln!("Error while closing DuckDB connection: {e:?}"); } else { - panic!("Error while closing DuckDB connection: {:?}", e); + panic!("Error while closing DuckDB connection: {e:?}"); } } } diff --git a/src/lib.rs b/src/lib.rs index 0befeafb..c723d140 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -187,7 +187,7 @@ impl<'a> fmt::Display for DatabaseName<'a> { match *self { DatabaseName::Main => write!(f, "main"), DatabaseName::Temp => write!(f, "temp"), - DatabaseName::Attached(s) => write!(f, "{}", s), + DatabaseName::Attached(s) => write!(f, "{s}"), } } } @@ -655,9 +655,7 @@ mod test { // assert_eq!(ErrorCode::CannotOpen, e.code); assert!( msg.contains(filename), - "error message '{}' does not contain '{}'", - msg, - filename + "error message '{msg}' does not contain '{filename}'" ); } else { panic!("DuckDBFailure expected"); @@ -854,7 +852,7 @@ mod test { let result: Result = db.query_row("SELECT x FROM foo WHERE x > 5", [], |r| r.get(0)); match result.unwrap_err() { Error::QueryReturnedNoRows => (), - err => panic!("Unexpected error {}", err), + err => panic!("Unexpected error {err}"), } let bad_query_result = db.query_row("NOT A PROPER QUERY; test123", [], |_| Ok(())); @@ -910,7 +908,7 @@ mod test { let query = "SELECT 12345"; let stmt = db.prepare(query)?; - assert!(format!("{:?}", stmt).contains(query)); + assert!(format!("{stmt:?}").contains(query)); Ok(()) } @@ -927,7 +925,7 @@ mod test { // TODO(wangfenjin): Update errorcode assert_eq!(err.code, ErrorCode::Unknown); } - err => panic!("Unexpected error {}", err), + err => panic!("Unexpected error {err}"), } Ok(()) } @@ -975,7 +973,7 @@ mod test { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { match *self { CustomError::SomeError => write!(f, "my custom error"), - CustomError::Sqlite(ref se) => write!(f, "my custom error: {}", se), + CustomError::Sqlite(ref se) => write!(f, "my custom error: {se}"), } } } @@ -1037,14 +1035,14 @@ mod test { match bad_type.unwrap_err() { Error::InvalidColumnType(..) => (), - err => panic!("Unexpected error {}", err), + err => panic!("Unexpected error {err}"), } let bad_idx: Result> = query.query_and_then([], |row| row.get(3))?.collect(); match bad_idx.unwrap_err() { Error::InvalidColumnIndex(_) => (), - err => panic!("Unexpected error {}", err), + err => panic!("Unexpected error {err}"), } Ok(()) } @@ -1089,7 +1087,7 @@ mod test { match bad_type.unwrap_err() { CustomError::Sqlite(Error::InvalidColumnType(..)) => (), - err => panic!("Unexpected error {}", err), + err => panic!("Unexpected error {err}"), } let bad_idx: CustomResult> = query @@ -1098,7 +1096,7 @@ mod test { match bad_idx.unwrap_err() { CustomError::Sqlite(Error::InvalidColumnIndex(_)) => (), - err => panic!("Unexpected error {}", err), + err => panic!("Unexpected error {err}"), } let non_sqlite_err: CustomResult> = @@ -1106,7 +1104,7 @@ mod test { match non_sqlite_err.unwrap_err() { CustomError::SomeError => (), - err => panic!("Unexpected error {}", err), + err => panic!("Unexpected error {err}"), } Ok(()) } @@ -1143,7 +1141,7 @@ mod test { match bad_type.unwrap_err() { CustomError::Sqlite(Error::InvalidColumnType(..)) => (), - err => panic!("Unexpected error {}", err), + err => panic!("Unexpected error {err}"), } let bad_idx: CustomResult = @@ -1151,7 +1149,7 @@ mod test { match bad_idx.unwrap_err() { CustomError::Sqlite(Error::InvalidColumnIndex(_)) => (), - err => panic!("Unexpected error {}", err), + err => panic!("Unexpected error {err}"), } let non_sqlite_err: CustomResult = @@ -1159,7 +1157,7 @@ mod test { match non_sqlite_err.unwrap_err() { CustomError::SomeError => (), - err => panic!("Unexpected error {}", err), + err => panic!("Unexpected error {err}"), } Ok(()) } diff --git a/src/pragma.rs b/src/pragma.rs index c488c547..9a0e3d16 100644 --- a/src/pragma.rs +++ b/src/pragma.rs @@ -33,7 +33,7 @@ impl Sql { } else { Err(Error::DuckDBFailure( ffi::Error::new(ffi::DuckDBError), - Some(format!("Invalid keyword \"{}\"", keyword)), + Some(format!("Invalid keyword \"{keyword}\"")), )) } } @@ -74,7 +74,7 @@ impl Sql { _ => { return Err(Error::DuckDBFailure( ffi::Error::new(ffi::DuckDBError), - Some(format!("Unsupported value \"{:?}\"", value)), + Some(format!("Unsupported value \"{value:?}\"")), )); } }; diff --git a/src/statement.rs b/src/statement.rs index 2feb81b9..9eb0cc5c 100644 --- a/src/statement.rs +++ b/src/statement.rs @@ -687,7 +687,7 @@ mod test { let mut multi = db.prepare("INSERT INTO foo (x) SELECT 3 UNION ALL SELECT 4")?; match multi.insert([]).unwrap_err() { Error::StatementChangedRows(2) => (), - err => panic!("Unexpected error {}", err), + err => panic!("Unexpected error {err}"), } Ok(()) } diff --git a/src/transaction.rs b/src/transaction.rs index f6138d03..3da3c9fa 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -249,7 +249,7 @@ impl Savepoint<'_> { #[inline] fn with_depth_and_name>(conn: &Connection, depth: u32, name: T) -> Result> { let name = name.into(); - conn.execute_batch(&format!("SAVEPOINT {}", name)).map(|_| Savepoint { + conn.execute_batch(&format!("SAVEPOINT {name}")).map(|_| Savepoint { conn, name, depth, @@ -260,7 +260,7 @@ impl Savepoint<'_> { #[inline] fn with_depth(conn: &Connection, depth: u32) -> Result> { - let name = format!("_duckdb_sp_{}", depth); + let name = format!("_duckdb_sp_{depth}"); Savepoint::with_depth_and_name(conn, depth, name) } diff --git a/src/types/chrono.rs b/src/types/chrono.rs index 12ffd043..8b1c0343 100644 --- a/src/types/chrono.rs +++ b/src/types/chrono.rs @@ -264,7 +264,7 @@ mod test { [Utc::now()], |r| r.get(0), ); - println!("{:?}", result); + println!("{result:?}"); assert!(result.is_ok()); Ok(()) } diff --git a/src/types/from_sql.rs b/src/types/from_sql.rs index b88cdb87..190f9bbb 100644 --- a/src/types/from_sql.rs +++ b/src/types/from_sql.rs @@ -41,10 +41,10 @@ impl fmt::Display for FromSqlError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { FromSqlError::InvalidType => write!(f, "Invalid type"), - FromSqlError::OutOfRange(i) => write!(f, "Value {} out of range", i), + FromSqlError::OutOfRange(i) => write!(f, "Value {i} out of range"), #[cfg(feature = "uuid")] FromSqlError::InvalidUuidSize(s) => { - write!(f, "Cannot read UUID value out of {} byte blob", s) + write!(f, "Cannot read UUID value out of {s} byte blob") } FromSqlError::Other(ref err) => err.fmt(f), } @@ -361,7 +361,7 @@ mod test { let err = db.query_row("SELECT ?", [n], |r| r.get::<_, T>(0)).unwrap_err(); match err { Error::IntegralValueOutOfRange(_, value) => assert_eq!(*n, value), - _ => panic!("unexpected error: {}", err), + _ => panic!("unexpected error: {err}"), } } for n in in_range { diff --git a/src/types/mod.rs b/src/types/mod.rs index 3dba9900..8446dae0 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -368,7 +368,7 @@ mod test { assert_eq!(Value::Int(1), row.get::<_, Value>(2)?); match row.get::<_, Value>(3)? { Value::Float(val) => assert!((1.5 - val).abs() < EPSILON as f32), - x => panic!("Invalid Value {:?}", x), + x => panic!("Invalid Value {x:?}"), } assert_eq!(Value::Null, row.get::<_, Value>(4)?); Ok(()) diff --git a/src/types/url.rs b/src/types/url.rs index 698312b9..9656b198 100644 --- a/src/types/url.rs +++ b/src/types/url.rs @@ -71,7 +71,7 @@ mod test { assert_eq!(*e.downcast::().unwrap(), ParseError::RelativeUrlWithoutBase,); } e => { - panic!("Expected conversion failure, got {}", e); + panic!("Expected conversion failure, got {e}"); } } Ok(())