From e1eed94bef6dbfe4e155c12f522ac7a5b02dd563 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sun, 28 Feb 2021 13:19:58 +0100 Subject: [PATCH 1/2] Fix clippy warnings Allow `unnecessary_wraps` for `check_update` and `check_no_tail`. Remove `check_readonly` (`sqlite3-parser` may help). --- src/raw_statement.rs | 1 + src/statement.rs | 18 ++---------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/raw_statement.rs b/src/raw_statement.rs index 28395a8..eda47fb 100644 --- a/src/raw_statement.rs +++ b/src/raw_statement.rs @@ -170,6 +170,7 @@ impl RawStatement { r } + // does not work for PRAGMA #[inline] #[cfg(all(feature = "extra_check", feature = "modern_sqlite"))] // 3.7.4 pub fn readonly(&self) -> bool { diff --git a/src/statement.rs b/src/statement.rs index e6419dc..e7171e7 100644 --- a/src/statement.rs +++ b/src/statement.rs @@ -220,7 +220,6 @@ impl Statement<'_> { /// Will return `Err` if binding parameters fails. #[inline] pub fn query(&mut self, params: P) -> Result> { - self.check_readonly()?; params.__bind_in(self)?; Ok(Rows::new(self)) } @@ -718,21 +717,6 @@ impl Statement<'_> { self.conn.decode_result(stmt.finalize()) } - #[cfg(not(feature = "modern_sqlite"))] - #[inline] - fn check_readonly(&self) -> Result<()> { - Ok(()) - } - - #[cfg(feature = "modern_sqlite")] - #[inline] - fn check_readonly(&self) -> Result<()> { - /*if !self.stmt.readonly() { does not work for PRAGMA - return Err(Error::InvalidQuery); - }*/ - Ok(()) - } - #[cfg(all(feature = "modern_sqlite", feature = "extra_check"))] #[inline] fn check_update(&self) -> Result<()> { @@ -755,6 +739,7 @@ impl Statement<'_> { #[cfg(not(feature = "extra_check"))] #[inline] + #[allow(clippy::unnecessary_wraps)] fn check_update(&self) -> Result<()> { Ok(()) } @@ -793,6 +778,7 @@ impl Statement<'_> { #[cfg(not(feature = "extra_check"))] #[inline] + #[allow(clippy::unnecessary_wraps)] pub(crate) fn check_no_tail(&self) -> Result<()> { Ok(()) } From bd736b26340ce8e6c735826a931966f951a9208c Mon Sep 17 00:00:00 2001 From: Thom Chiovoloni Date: Tue, 2 Mar 2021 18:19:11 -0800 Subject: [PATCH 2/2] Fix nightly non_fmt_panic warning --- src/inner_connection.rs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/inner_connection.rs b/src/inner_connection.rs index 133b7ef..60c6a97 100644 --- a/src/inner_connection.rs +++ b/src/inner_connection.rs @@ -424,18 +424,14 @@ fn ensure_safe_sqlite_threading_mode() -> Result<()> { } unsafe { - let msg = "\ -Could not ensure safe initialization of SQLite. -To fix this, either: -* Upgrade SQLite to at least version 3.7.0 -* Ensure that SQLite has been initialized in Multi-thread or Serialized mode and call - rusqlite::bypass_sqlite_initialization() prior to your first connection attempt."; - - if ffi::sqlite3_config(ffi::SQLITE_CONFIG_MULTITHREAD) != ffi::SQLITE_OK { - panic!(msg); - } - if ffi::sqlite3_initialize() != ffi::SQLITE_OK { - panic!(msg); + if ffi::sqlite3_config(ffi::SQLITE_CONFIG_MULTITHREAD) != ffi::SQLITE_OK || ffi::sqlite3_initialize() != ffi::SQLITE_OK { + panic!( + "Could not ensure safe initialization of SQLite.\n\ + To fix this, either:\n\ + * Upgrade SQLite to at least version 3.7.0\n\ + * Ensure that SQLite has been initialized in Multi-thread or Serialized mode and call\n\ + rusqlite::bypass_sqlite_initialization() prior to your first connection attempt." + ); } } });