Skip to content

Commit cde5419

Browse files
committed
Use an even more minimal health check
1 parent 2a7dde1 commit cde5419

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl r2d2::PoolManager<PostgresConnection, Error> for PostgresPoolManager {
4444
}
4545

4646
fn is_valid(&self, conn: &mut PostgresConnection) -> Result<(), Error> {
47-
conn.batch_execute("SELECT 1").map_err(OtherError)
47+
conn.batch_execute("").map_err(OtherError)
4848
}
4949

5050
fn has_broken(&self, conn: &mut PostgresConnection) -> bool {

tests/test.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,17 @@ fn test_basic() {
6868

6969
pool.get().unwrap();
7070
}
71+
72+
#[test]
73+
fn test_is_valid() {
74+
let manager = PostgresPoolManager::new("postgres://postgres@localhost", NoSsl);
75+
let config = r2d2::Config {
76+
pool_size: 1,
77+
test_on_check_out: true,
78+
..Default::default()
79+
};
80+
let handler = r2d2::NoopErrorHandler;
81+
let pool = r2d2::Pool::new(config, manager, handler).unwrap();
82+
83+
pool.get().unwrap();
84+
}

0 commit comments

Comments
 (0)