diff --git a/src/main/scala/com/twitter/finagle/postgres/PostgresClientImpl.scala b/src/main/scala/com/twitter/finagle/postgres/PostgresClientImpl.scala index 55ae3492..3e8199f0 100644 --- a/src/main/scala/com/twitter/finagle/postgres/PostgresClientImpl.scala +++ b/src/main/scala/com/twitter/finagle/postgres/PostgresClientImpl.scala @@ -154,25 +154,32 @@ class PostgresClientImpl( * Issue a single, prepared SELECT query and wrap the response rows with the provided function. */ override def prepareAndQuery[T](sql: String, params: Param[_]*)(f: Row => T): Future[Seq[T]] = { - for { - service <- factory() - statement = new PreparedStatementImpl("", sql, service) - result <- statement.select(params: _*)(f) - } yield result + typeMap().flatMap { _ => + for { + service <- factory() + statement = new PreparedStatementImpl("", sql, service) + result <- statement.select(params: _*)(f) + } yield result + } } /* * Issue a single, prepared arbitrary query without an expected result set, and provide the affected row count */ - override def prepareAndExecute(sql: String, params: Param[_]*):Future[Int] = for { - service <- factory() - statement = new PreparedStatementImpl("", sql, service) - OK(count) <- statement.exec(params: _*) - } yield count + override def prepareAndExecute(sql: String, params: Param[_]*): Future[Int] = { + typeMap().flatMap { _ => + for { + service <- factory() + statement = new PreparedStatementImpl("", sql, service) + OK(count) <- statement.exec(params: _*) + } yield count + } + } /** * Close the underlying connection pool and make this Client eternally down + * * @return */ override def close(): Future[Unit] = {