diff --git a/examples/appender.rs b/examples/appender.rs index b2ba0c6a..c159829d 100644 --- a/examples/appender.rs +++ b/examples/appender.rs @@ -1,5 +1,4 @@ extern crate duckdb; -use std::convert::TryFrom; use duckdb::{params, Connection, DropBehavior, Result}; diff --git a/src/appender/mod.rs b/src/appender/mod.rs index 195c2d8b..7db98e2d 100644 --- a/src/appender/mod.rs +++ b/src/appender/mod.rs @@ -1,5 +1,5 @@ use super::{ffi, AppenderParams, Connection, Result, ValueRef}; -use std::{ffi::c_void, fmt, iter::IntoIterator, os::raw::c_char}; +use std::{ffi::c_void, fmt, os::raw::c_char}; use crate::{ error::result_from_duckdb_appender, @@ -170,7 +170,6 @@ impl fmt::Debug for Appender<'_> { #[cfg(test)] mod test { use crate::{Connection, Result}; - use std::convert::TryFrom; #[test] fn test_append_one_row() -> Result<()> { diff --git a/src/lib.rs b/src/lib.rs index 6737cf88..129e51c5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -60,7 +60,6 @@ pub use libduckdb_sys as ffi; use std::{ cell::RefCell, convert, - default::Default, ffi::CString, fmt, path::{Path, PathBuf}, diff --git a/src/r2d2.rs b/src/r2d2.rs index b05225e5..75203671 100644 --- a/src/r2d2.rs +++ b/src/r2d2.rs @@ -102,7 +102,7 @@ impl r2d2::ManageConnection for DuckdbConnectionManager { mod test { extern crate r2d2; use super::*; - use crate::{types::Value, Result}; + use crate::types::Value; use std::{sync::mpsc, thread}; use tempdir::TempDir; diff --git a/src/raw_statement.rs b/src/raw_statement.rs index a94eaba4..a99f8022 100644 --- a/src/raw_statement.rs +++ b/src/raw_statement.rs @@ -1,4 +1,4 @@ -use std::{convert::TryFrom, ffi::CStr, ptr, rc::Rc, sync::Arc}; +use std::{ffi::CStr, ptr, rc::Rc, sync::Arc}; use arrow::{ array::StructArray, diff --git a/src/statement.rs b/src/statement.rs index 7e5815fc..810399a9 100644 --- a/src/statement.rs +++ b/src/statement.rs @@ -1,4 +1,4 @@ -use std::{convert, ffi::c_void, fmt, iter::IntoIterator, mem, os::raw::c_char, ptr, str}; +use std::{convert, ffi::c_void, fmt, mem, os::raw::c_char, ptr, str}; use arrow::{array::StructArray, datatypes::DataType}; diff --git a/src/types/chrono.rs b/src/types/chrono.rs index dea18b8e..e4f9365c 100644 --- a/src/types/chrono.rs +++ b/src/types/chrono.rs @@ -63,12 +63,15 @@ impl FromSql for NaiveDateTime { TimeUnit::Microsecond => (t / 1_000_000, (t % 1_000_000) * 1000), TimeUnit::Nanosecond => (t / 1_000_000_000, t % 1_000_000_000), }; - Ok(NaiveDateTime::from_timestamp_opt(secs, nsecs as u32).unwrap()) - } - ValueRef::Date32(d) => Ok(NaiveDateTime::from_timestamp_opt(24 * 3600 * (d as i64), 0).unwrap()), - ValueRef::Time64(TimeUnit::Microsecond, d) => { - Ok(NaiveDateTime::from_timestamp_opt(d / 1_000_000, ((d % 1_000_000) * 1_000) as u32).unwrap()) + Ok(DateTime::from_timestamp(secs, nsecs as u32).unwrap().naive_utc()) } + ValueRef::Date32(d) => Ok(DateTime::from_timestamp(24 * 3600 * (d as i64), 0).unwrap().naive_utc()), + ValueRef::Time64(TimeUnit::Microsecond, d) => Ok(DateTime::from_timestamp( + d / 1_000_000, + ((d % 1_000_000) * 1_000) as u32, + ) + .unwrap() + .naive_utc()), ValueRef::Text(s) => { let mut s = std::str::from_utf8(s).unwrap(); let format = match s.len() { @@ -206,7 +209,7 @@ mod test { assert_eq!(utc, v2); let v3: DateTime = db.query_row("SELECT '2016-02-23 23:56:04'", [], |r| r.get(0))?; - assert_eq!(utc - Duration::milliseconds(789), v3); + assert_eq!(utc - Duration::try_milliseconds(789).unwrap(), v3); let v4: DateTime = db.query_row("SELECT '2016-02-23 23:56:04.789+00:00'", [], |r| r.get(0))?; assert_eq!(utc, v4); diff --git a/src/types/from_sql.rs b/src/types/from_sql.rs index b784f098..85b1881d 100644 --- a/src/types/from_sql.rs +++ b/src/types/from_sql.rs @@ -272,7 +272,6 @@ impl FromSql for Value { mod test { use super::FromSql; use crate::{Connection, Error, Result}; - use std::convert::TryFrom; #[test] fn test_timestamp_raw() -> Result<()> { diff --git a/src/vtab/arrow.rs b/src/vtab/arrow.rs index 277a85d2..e6d7eb92 100644 --- a/src/vtab/arrow.rs +++ b/src/vtab/arrow.rs @@ -6,8 +6,8 @@ use super::{ use crate::vtab::vector::Inserter; use arrow::array::{ as_boolean_array, as_large_list_array, as_list_array, as_primitive_array, as_string_array, Array, ArrayData, - ArrowPrimitiveType, BooleanArray, Decimal128Array, FixedSizeListArray, GenericListArray, OffsetSizeTrait, - PrimitiveArray, StringArray, StructArray, + BooleanArray, Decimal128Array, FixedSizeListArray, GenericListArray, OffsetSizeTrait, PrimitiveArray, StringArray, + StructArray, }; use arrow::{ diff --git a/src/vtab/mod.rs b/src/vtab/mod.rs index 678ecd71..22937e3e 100644 --- a/src/vtab/mod.rs +++ b/src/vtab/mod.rs @@ -163,7 +163,6 @@ impl InnerConnection { #[cfg(test)] mod test { use super::*; - use crate::{Connection, Result}; use std::{ error::Error, ffi::{c_char, CString},