Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ lazy val publishSettings = Seq(

lazy val allSettings = baseSettings ++ buildSettings ++ publishSettings

lazy val root = project.in(file("."))
lazy val `finagle-postgres` = project.in(file("."))
.settings(moduleName := "finagle-postgres")
.settings(allSettings)
.configs(IntegrationTest)
Expand Down
16 changes: 15 additions & 1 deletion src/main/scala/com/twitter/finagle/postgres/Client.scala
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ class Client(factory: ServiceFactory[PgRequest, PgResponse], id:String) {
service =>
parse(sql, Some(service)).map { name =>
new PreparedStatementImpl(name, service)
}.rescue {
case err => sync(Some(service)).flatMap {
_ =>
service.close().flatMap {
_ => Future.exception(err)
}
}
}
}

Expand All @@ -100,7 +107,14 @@ class Client(factory: ServiceFactory[PgRequest, PgResponse], id:String) {
service =>
parse(sql, Some(service)).map { name =>
new PreparedStatementImpl(name, service)
}
}.rescue {
case err => sync(Some(service)).flatMap {
_ =>
service.close().flatMap {
_ => Future.exception(err)
}
}
}
}

preparedStatement.flatMap {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,15 @@ class IntegrationSpec extends Spec {
}
}

"query in a prepared statement has an error" in {
if(postgresAvailable) {
val client = getClient
a [ServerError] must be thrownBy {
Await.result(client.prepareAndQuery("Garbage query")(identity))
}
}
}

"prepared query is missing parameters" in {
if (postgresAvailable) {
val client = getClient
Expand Down