From 70b59f9c2c974c5c27acdb0f007e3ffd3d6a1197 Mon Sep 17 00:00:00 2001 From: gwenn Date: Wed, 12 Sep 2018 22:16:22 +0200 Subject: [PATCH] Impossible to execute a pragma in 0.14.0 #400 sqlite3_stmt_readonly does not work for PRAGMA. --- src/lib.rs | 16 ++++++++++++++++ src/statement.rs | 6 ++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index b6023dc..d23d86b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1360,6 +1360,22 @@ mod test { assert!(bad_query_result.is_err()); } + #[test] + fn test_pragma_query_row() { + let db = checked_memory_handle(); + + assert_eq!( + "memory", + db.query_row::("PRAGMA journal_mode", &[], |r| r.get(0)) + .unwrap() + ); + assert_eq!( + "off", + db.query_row::("PRAGMA journal_mode=off", &[], |r| r.get(0)) + .unwrap() + ); + } + #[test] fn test_prepare_failures() { let db = checked_memory_handle(); diff --git a/src/statement.rs b/src/statement.rs index f2b239a..7130f22 100644 --- a/src/statement.rs +++ b/src/statement.rs @@ -516,15 +516,17 @@ impl<'conn> Statement<'conn> { } #[cfg(not(feature = "bundled"))] + #[inline] fn check_readonly(&self) -> Result<()> { Ok(()) } #[cfg(feature = "bundled")] + #[inline] fn check_readonly(&self) -> Result<()> { - if !self.stmt.readonly() { + /*if !self.stmt.readonly() { does not work for PRAGMA return Err(Error::InvalidQuery); - } + }*/ Ok(()) }