From 3d30104c3015e15c211047b5d08d80af813956b8 Mon Sep 17 00:00:00 2001 From: John Gallagher Date: Thu, 19 May 2016 15:01:22 -0500 Subject: [PATCH 01/13] Teach clippy about allowed doc markdown identifiers --- clippy.toml | 1 + 1 file changed, 1 insertion(+) create mode 100644 clippy.toml diff --git a/clippy.toml b/clippy.toml new file mode 100644 index 0000000..82447d9 --- /dev/null +++ b/clippy.toml @@ -0,0 +1 @@ +doc-valid-idents = ["SQLite", "lang_transaction"] From 6f8f2f3910146888d659cfc161dac4f243f59f8d Mon Sep 17 00:00:00 2001 From: John Gallagher Date: Thu, 19 May 2016 15:02:06 -0500 Subject: [PATCH 02/13] Fix clippy match_same_arms warning --- src/error.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/error.rs b/src/error.rs index 22f79a6..1d6ccd4 100644 --- a/src/error.rs +++ b/src/error.rs @@ -160,8 +160,8 @@ impl error::Error for Error { Error::InvalidColumnIndex(_) | Error::InvalidColumnName(_) | Error::InvalidColumnType | - Error::InvalidPath(_) => None, - Error::StatementChangedRows(_) => None, + Error::InvalidPath(_) | + Error::StatementChangedRows(_) | Error::StatementFailedToInsertRow => None, #[cfg(feature = "functions")] From 57d2ae42cfe027fcf8d65bcf3be88b7c24540ef9 Mon Sep 17 00:00:00 2001 From: John Gallagher Date: Thu, 19 May 2016 15:03:01 -0500 Subject: [PATCH 03/13] Fix clippy needless_borrow warning --- src/cache.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cache.rs b/src/cache.rs index f5fade3..ce9181e 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -34,7 +34,7 @@ impl Connection { /// Will return `Err` if `sql` cannot be converted to a C-compatible string or if the /// underlying SQLite call fails. pub fn prepare_cached<'a>(&'a self, sql: &str) -> Result> { - self.cache.get(&self, sql) + self.cache.get(self, sql) } /// Set the maximum number of cached prepared statements this connection will hold. From 71aa41c27a0f84eb31c7c058ec4008b4cc17d823 Mon Sep 17 00:00:00 2001 From: John Gallagher Date: Thu, 19 May 2016 20:04:33 -0500 Subject: [PATCH 04/13] rustfmt --- src/lib.rs | 4 +--- src/named_params.rs | 25 ++++++++++++++----------- src/transaction.rs | 9 +++++++-- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index c3b565e..911667f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -965,9 +965,7 @@ pub struct Rows<'stmt> { impl<'stmt> Rows<'stmt> { fn new(stmt: &'stmt Statement<'stmt>) -> Rows<'stmt> { - Rows { - stmt: Some(stmt), - } + Rows { stmt: Some(stmt) } } fn get_expected_row<'a>(&'a mut self) -> Result> { diff --git a/src/named_params.rs b/src/named_params.rs index 04ebcbd..d89cc6e 100644 --- a/src/named_params.rs +++ b/src/named_params.rs @@ -279,9 +279,10 @@ mod test { let mut stmt = db.prepare("SELECT id FROM test where name = :name").unwrap(); let mut rows = stmt.query_map_named(&[(":name", &"one")], |row| { - let id: i32 = row.get(0); - 2 * id - }).unwrap(); + let id: i32 = row.get(0); + 2 * id + }) + .unwrap(); let doubled_id: i32 = rows.next().unwrap().unwrap(); assert_eq!(2, doubled_id); @@ -298,15 +299,17 @@ mod test { "#; db.execute_batch(sql).unwrap(); - let mut stmt = db.prepare("SELECT id FROM test where name = :name ORDER BY id ASC").unwrap(); + let mut stmt = db.prepare("SELECT id FROM test where name = :name ORDER BY id ASC") + .unwrap(); let mut rows = stmt.query_and_then_named(&[(":name", &"one")], |row| { - let id: i32 = row.get(0); - if id == 1 { - Ok(id) - } else { - Err(Error::SqliteSingleThreadedMode) - } - }).unwrap(); + let id: i32 = row.get(0); + if id == 1 { + Ok(id) + } else { + Err(Error::SqliteSingleThreadedMode) + } + }) + .unwrap(); // first row should be Ok let doubled_id: i32 = rows.next().unwrap().unwrap(); diff --git a/src/transaction.rs b/src/transaction.rs index 3bdae80..e678215 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -209,7 +209,10 @@ impl<'conn> Drop for Transaction<'conn> { } impl<'conn> Savepoint<'conn> { - fn with_depth_and_name>(conn: &Connection, depth: u32, name: T) -> Result { + fn with_depth_and_name>(conn: &Connection, + depth: u32, + name: T) + -> Result { let name = name.into(); conn.execute_batch(&format!("SAVEPOINT {}", name)).map(|_| { Savepoint { @@ -349,7 +352,9 @@ impl Connection { /// # Failure /// /// Will return `Err` if the underlying SQLite call fails. - pub fn transaction_with_behavior(&mut self, behavior: TransactionBehavior) -> Result { + pub fn transaction_with_behavior(&mut self, + behavior: TransactionBehavior) + -> Result { Transaction::new(self, behavior) } From c4417bee0e7694ee4263dccbaca88c73da3dbd94 Mon Sep 17 00:00:00 2001 From: John Gallagher Date: Thu, 19 May 2016 20:09:40 -0500 Subject: [PATCH 05/13] Manual fixes for rustfmt overly long lines. --- src/blob.rs | 5 ++++- src/functions.rs | 17 ++++++++++------- src/lib.rs | 9 +++++++-- src/trace.rs | 6 ++++-- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/blob.rs b/src/blob.rs index c24fce9..548e5c9 100644 --- a/src/blob.rs +++ b/src/blob.rs @@ -235,7 +235,10 @@ impl<'conn> Drop for Blob<'conn> { } /// BLOB of length N that is filled with zeroes. -/// Zeroblobs are intended to serve as placeholders for BLOBs whose content is later written using incremental BLOB I/O routines. +/// +/// Zeroblobs are intended to serve as placeholders for BLOBs whose content is later written using +/// incremental BLOB I/O routines. +/// /// A negative value for the zeroblob results in a zero-length BLOB. #[derive(Copy,Clone)] pub struct ZeroBlob(pub i32); diff --git a/src/functions.rs b/src/functions.rs index 5842880..8c8723e 100644 --- a/src/functions.rs +++ b/src/functions.rs @@ -111,7 +111,8 @@ impl<'a> ToResult for &'a str { length as c_int, ffi::SQLITE_TRANSIENT()) } - Err(_) => ffi::sqlite3_result_error_code(ctx, ffi::SQLITE_MISUSE), // TODO sqlite3_result_error + // TODO sqlite3_result_error + Err(_) => ffi::sqlite3_result_error_code(ctx, ffi::SQLITE_MISUSE), } } } @@ -710,9 +711,10 @@ mod test { assert_eq!(true, result.unwrap()); - let result: Result = db.query_row("SELECT COUNT(*) FROM foo WHERE regexp('l.s[aeiouy]', x) == 1", - &[], - |r| r.get(0)); + let result: Result = + db.query_row("SELECT COUNT(*) FROM foo WHERE regexp('l.s[aeiouy]', x) == 1", + &[], + |r| r.get(0)); assert_eq!(2, result.unwrap()); } @@ -760,9 +762,10 @@ mod test { assert_eq!(true, result.unwrap()); - let result: Result = db.query_row("SELECT COUNT(*) FROM foo WHERE regexp('l.s[aeiouy]', x) == 1", - &[], - |r| r.get(0)); + let result: Result = + db.query_row("SELECT COUNT(*) FROM foo WHERE regexp('l.s[aeiouy]', x) == 1", + &[], + |r| r.get(0)); assert_eq!(2, result.unwrap()); } diff --git a/src/lib.rs b/src/lib.rs index 911667f..f68da9c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -319,7 +319,9 @@ impl Connection { /// ```rust,no_run /// # use rusqlite::{Result,Connection}; /// fn preferred_locale(conn: &Connection) -> Result { - /// conn.query_row_and_then("SELECT value FROM preferences WHERE name='locale'", &[], |row| { + /// conn.query_row_and_then("SELECT value FROM preferences WHERE name='locale'", + /// &[], + /// |row| { /// row.get_checked(0) /// }) /// } @@ -709,9 +711,12 @@ impl<'conn> Statement<'conn> { } /// Returns the column index in the result set for a given column name. - /// If there is no AS clause then the name of the column is unspecified and may change from one release of SQLite to the next. + /// + /// If there is no AS clause then the name of the column is unspecified and may change from one + /// release of SQLite to the next. /// /// # Failure + /// /// Will return an `Error::InvalidColumnName` when there is no column with the specified `name`. pub fn column_index(&self, name: &str) -> Result { let bytes = name.as_bytes(); diff --git a/src/trace.rs b/src/trace.rs index 4cea711..32382a2 100644 --- a/src/trace.rs +++ b/src/trace.rs @@ -59,7 +59,8 @@ pub fn log(err_code: c_int, msg: &str) { } impl Connection { - /// Register or clear a callback function that can be used for tracing the execution of SQL statements. + /// Register or clear a callback function that can be used for tracing the execution of SQL + /// statements. /// /// Prepared statement placeholders are replaced/logged with their assigned values. /// There can only be a single tracer defined for each database connection. @@ -83,7 +84,8 @@ impl Connection { } } - /// Register or clear a callback function that can be used for profiling the execution of SQL statements. + /// Register or clear a callback function that can be used for profiling the execution of SQL + /// statements. /// /// There can only be a single profiler defined for each database connection. /// Setting a new profiler clears the old one. From 0dfaf2816ffbfbfa65ba59e8fb74d8426f9a496c Mon Sep 17 00:00:00 2001 From: John Gallagher Date: Thu, 19 May 2016 20:16:09 -0500 Subject: [PATCH 06/13] Update feature list in doc-publishing script --- publish-ghp-docs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/publish-ghp-docs.sh b/publish-ghp-docs.sh index c8fc790..a6883bc 100755 --- a/publish-ghp-docs.sh +++ b/publish-ghp-docs.sh @@ -8,7 +8,7 @@ fi cd $(git rev-parse --show-toplevel) rm -rf target/doc/ -multirust run nightly cargo doc --no-deps --features "backup cache functions load_extension trace blob" +rustup run nightly cargo doc --no-deps --features "backup blob chrono functions load_extension serde_json trace" echo '' > target/doc/index.html ghp-import target/doc git push origin gh-pages:gh-pages From e3b7d9612f315ee17c9c58f48dfd5ae865e6c898 Mon Sep 17 00:00:00 2001 From: John Gallagher Date: Thu, 19 May 2016 20:20:58 -0500 Subject: [PATCH 07/13] Add new features to README. --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 05635c7..2f8d23c 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,12 @@ features](http://doc.crates.io/manifest.html#the-features-section). They are: allows hooks into SQLite's tracing and profiling APIs. * [`blob`](http://jgallagher.github.io/rusqlite/rusqlite/blob/index.html) gives `std::io::{Read, Write, Seek}` access to SQL BLOBs. +* `chrono` implements [`FromSql`](http://jgallagher.github.io/rusqlite/rusqlite/types/trait.FromSql.html) + and [`ToSql`](http://jgallagher.github.io/rusqlite/rusqlite/types/trait.ToSql.html) for various + types from the [`chrono` crate](https://crates.io/crates/chrono). +* `serde_json` implements [`FromSql`](http://jgallagher.github.io/rusqlite/rusqlite/types/trait.FromSql.html) + and [`ToSql`](http://jgallagher.github.io/rusqlite/rusqlite/types/trait.ToSql.html) for the + `Value` type from the [`serde_json` crate](https://crates.io/crates/serde_json). ## Author From 9379002076456a9fc59ad44ae05aeb71c6f6720f Mon Sep 17 00:00:00 2001 From: John Gallagher Date: Thu, 19 May 2016 20:25:40 -0500 Subject: [PATCH 08/13] Bump to version 0.7.0. Also bumps libsqlite3-sys to 0.5.0. --- Cargo.toml | 4 ++-- Changelog.md | 2 +- libsqlite3-sys/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3babbc3..be82e3f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rusqlite" -version = "0.6.0" +version = "0.7.0" authors = ["John Gallagher "] description = "Ergonomic wrapper for SQLite" repository = "https://github.com/jgallagher/rusqlite" @@ -35,7 +35,7 @@ regex = "~0.1.41" [dependencies.libsqlite3-sys] path = "libsqlite3-sys" -version = "0.4.0" +version = "0.5.0" [[test]] name = "config_log" diff --git a/Changelog.md b/Changelog.md index df401e1..9667c32 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,4 +1,4 @@ -# Version UPCOMING (...) +# Version 0.7.0 (2016-05-19) * BREAKING CHANGE: `Rows` no longer implements `Iterator`. It still has a `next()` method, but the lifetime of the returned `Row` is now tied to the lifetime of the vending `Rows` object. diff --git a/libsqlite3-sys/Cargo.toml b/libsqlite3-sys/Cargo.toml index b93650b..90e2813 100644 --- a/libsqlite3-sys/Cargo.toml +++ b/libsqlite3-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libsqlite3-sys" -version = "0.4.0" +version = "0.5.0" authors = ["John Gallagher "] repository = "https://github.com/jgallagher/rusqlite" description = "Native bindings to the libsqlite3 library" From d27ed0de637d2d4b8ecc066d285ba6a7fd457223 Mon Sep 17 00:00:00 2001 From: John Gallagher Date: Thu, 19 May 2016 20:32:17 -0500 Subject: [PATCH 09/13] Re-export Savepoint. --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index f68da9c..03b61f7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -80,7 +80,7 @@ use error::{error_from_sqlite_code, error_from_handle}; use raw_statement::RawStatement; use cache::StatementCache; -pub use transaction::{SqliteTransaction, Transaction, TransactionBehavior}; +pub use transaction::{SqliteTransaction, Savepoint, Transaction, TransactionBehavior}; pub use error::{SqliteError, Error}; pub use cache::CachedStatement; From 84985dbd840aaa65dc338760c9d5751b8b90e3cc Mon Sep 17 00:00:00 2001 From: John Gallagher Date: Thu, 19 May 2016 20:32:57 -0500 Subject: [PATCH 10/13] Bump to 0.7.1 --- Cargo.toml | 2 +- Changelog.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index be82e3f..70c22ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rusqlite" -version = "0.7.0" +version = "0.7.1" authors = ["John Gallagher "] description = "Ergonomic wrapper for SQLite" repository = "https://github.com/jgallagher/rusqlite" diff --git a/Changelog.md b/Changelog.md index 9667c32..6c9e5f3 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,4 +1,4 @@ -# Version 0.7.0 (2016-05-19) +# Version 0.7.1 (2016-05-19) * BREAKING CHANGE: `Rows` no longer implements `Iterator`. It still has a `next()` method, but the lifetime of the returned `Row` is now tied to the lifetime of the vending `Rows` object. From dc1b0e39ed8d5e312e0747a063649d75ee3b02c3 Mon Sep 17 00:00:00 2001 From: John Gallagher Date: Thu, 19 May 2016 20:35:27 -0500 Subject: [PATCH 11/13] Re-export DropBehavior and SqliteTransactionBehavior. --- src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 03b61f7..f646558 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -80,7 +80,8 @@ use error::{error_from_sqlite_code, error_from_handle}; use raw_statement::RawStatement; use cache::StatementCache; -pub use transaction::{SqliteTransaction, Savepoint, Transaction, TransactionBehavior}; +pub use transaction::{SqliteTransaction, SqliteTransactionBehavior, DropBehavior, Savepoint, + Transaction, TransactionBehavior}; pub use error::{SqliteError, Error}; pub use cache::CachedStatement; From 8ce2f5888fcbc81a957c1f86b1c681607cf780e9 Mon Sep 17 00:00:00 2001 From: John Gallagher Date: Thu, 19 May 2016 20:36:41 -0500 Subject: [PATCH 12/13] Document CachedStatement::discard. --- src/cache.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cache.rs b/src/cache.rs index ce9181e..d246e8e 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -90,6 +90,8 @@ impl<'conn> CachedStatement<'conn> { } } + /// Discard the statement, preventing it from being returned to its `Connection`'s collection + /// of cached statements. pub fn discard(mut self) { self.stmt = None; } From 1950158c87ed1874b30a5988d783537358fac594 Mon Sep 17 00:00:00 2001 From: John Gallagher Date: Thu, 19 May 2016 20:38:17 -0500 Subject: [PATCH 13/13] Bump to 0.7.2 --- Cargo.toml | 2 +- Changelog.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 70c22ad..df70e47 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rusqlite" -version = "0.7.1" +version = "0.7.2" authors = ["John Gallagher "] description = "Ergonomic wrapper for SQLite" repository = "https://github.com/jgallagher/rusqlite" diff --git a/Changelog.md b/Changelog.md index 6c9e5f3..358d93f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,4 +1,4 @@ -# Version 0.7.1 (2016-05-19) +# Version 0.7.2 (2016-05-19) * BREAKING CHANGE: `Rows` no longer implements `Iterator`. It still has a `next()` method, but the lifetime of the returned `Row` is now tied to the lifetime of the vending `Rows` object.