8000 remove error parsed statement · mauricio/postgresql-async@75f0cfb · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Dec 3, 2019. It is now read-only.

Commit 75f0cfb

Browse files
committed
remove error parsed statement
1 parent 2e7ca4e commit 75f0cfb

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

postgresql-async/src/main/scala/com/github/mauricio/async/db/postgresql/PostgreSQLConnection.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ class PostgreSQLConnection
150150
this.disconnect
151151
}
152152

153+
this.currentPreparedStatement.map(p => this.parsedStatements.remove(p.query))
153154
this.currentPreparedStatement = None
154155
this.failQueryPromise(e)
155156
}

postgresql-async/src/main/scala/com/github/mauricio/async/db/postgresql/PreparedStatementHolder.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package com.github.mauricio.async.db.postgresql
1818

1919
import com.github.mauricio.async.db.postgresql.messages.backend.PostgreSQLColumnData
2020

21-
class PreparedStatementHolder( query : String, val statementId : Int ) {
21+
class PreparedStatementHolder(val query : String, val statementId : Int ) {
2222

2323
val (realQuery, paramsCount) = {
2424
val result = new StringBuilder(query.length+16)

postgresql-async/src/test/scala/com/github/mauricio/async/db/postgresql/PreparedStatementSpec.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import org.joda.time.LocalDate
2121
import com.github.mauricio.async.db.util.Log
2222
import com.github.mauricio.async.db.exceptions.InsufficientParametersException
2323
import java.util.Date
24+
import com.github.mauricio.async.db.postgresql.exceptions.GenericDatabaseException
2425

2526
class PreparedStatementSpec extends Specification with DatabaseTestHelper {
2627

@@ -265,6 +266,22 @@ class PreparedStatementSpec extends Specification with DatabaseTestHelper {
265266
}
266267
}
267268

269+
"run prepared statement twice with bad and good values" in {
270+
withHandler {
271+
handler =>
272+
val content = "Some Moment"
273+
274+
val query = "SELECT content FROM messages WHERE id = ?"
275+
276+
executeDdl(handler, messagesCreate)
277+
executePreparedStatement(handler, this.messagesInsert, Array(Some(content), None))
278+
279+
executePreparedStatement(handler, query, Array("undefined")) must throwA[GenericDatabaseException]
280+
val result = executePreparedStatement(handler, query, Array(1)).rows.get
281+
result(0)(0) === content
282+
}
283+
}
284+
268285
}
269286

270287
}

0 commit comments

Comments
 (0)
0