Skip to content

Commit 3cf715d

Browse files
authored
Add is-valid feature to allow disabling the "SELECT 1;" is_valid query (#69)
1 parent 8f81179 commit 3cf715d

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ features = ["trace"]
3939

4040

4141
[features]
42+
default = ["is-valid"]
4243
bundled = ["rusqlite/bundled"]
4344
bundled-sqlcipher = ["rusqlite/bundled-sqlcipher"]
4445
bundled-sqlcipher-vendored-openssl = [
4546
"rusqlite/bundled-sqlcipher-vendored-openssl",
4647
]
48+
is-valid = []

src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,13 @@ impl r2d2::ManageConnection for SqliteConnectionManager {
161161
}
162162

163163
fn is_valid(&self, conn: &mut Connection) -> Result<(), Error> {
164-
conn.execute_batch("SELECT 1;").map_err(Into::into)
164+
conn.execute_batch(
165+
#[cfg(feature = "is-valid")]
166+
"SELECT 1;", // This query can cause performance issues and also may cause errors on non-standard SQLite implementations.
167+
#[cfg(not(feature = "is-valid"))]
168+
"",
169+
)
170+
.map_err(Into::into)
165171
}
166172

167173
fn has_broken(&self, _: &mut Connection) -> bool {

0 commit comments

Comments
 (0)