mirror of
				https://github.com/isar/rusqlite.git
				synced 2025-10-31 05:48:56 +08:00 
			
		
		
		
	Add Statement.readonly() accessor
Remove cfg(extra_check) from RawStatement::readonly()
This commit is contained in:
		| @@ -197,7 +197,6 @@ impl RawStatement { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     // does not work for PRAGMA |     // does not work for PRAGMA | ||||||
|     #[cfg(feature = "extra_check")] |  | ||||||
|     #[inline] |     #[inline] | ||||||
|     pub fn readonly(&self) -> bool { |     pub fn readonly(&self) -> bool { | ||||||
|         unsafe { ffi::sqlite3_stmt_readonly(self.ptr) != 0 } |         unsafe { ffi::sqlite3_stmt_readonly(self.ptr) != 0 } | ||||||
|   | |||||||
| @@ -709,6 +709,12 @@ impl Statement<'_> { | |||||||
|         self.stmt.is_explain() |         self.stmt.is_explain() | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /// Returns true if the statement is read only. | ||||||
|  |     #[inline] | ||||||
|  |     pub fn readonly(&self) -> bool { | ||||||
|  |         self.stmt.readonly() | ||||||
|  |     } | ||||||
|  |  | ||||||
|     #[cfg(feature = "extra_check")] |     #[cfg(feature = "extra_check")] | ||||||
|     #[inline] |     #[inline] | ||||||
|     pub(crate) fn check_no_tail(&self) -> Result<()> { |     pub(crate) fn check_no_tail(&self) -> Result<()> { | ||||||
| @@ -1324,6 +1330,14 @@ mod test { | |||||||
|         Ok(()) |         Ok(()) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     #[test] | ||||||
|  |     fn readonly() -> Result<()> { | ||||||
|  |         let db = Connection::open_in_memory()?; | ||||||
|  |         let stmt = db.prepare("SELECT 1;")?; | ||||||
|  |         assert!(stmt.readonly()); | ||||||
|  |         Ok(()) | ||||||
|  |     } | ||||||
|  |  | ||||||
|     #[test] |     #[test] | ||||||
|     #[cfg(feature = "modern_sqlite")] // SQLite >= 3.38.0 |     #[cfg(feature = "modern_sqlite")] // SQLite >= 3.38.0 | ||||||
|     fn test_error_offset() -> Result<()> { |     fn test_error_offset() -> Result<()> { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user