Skip to content

Commit 870c782

Browse files
committed
Fix prepared statements regression
1 parent 9b96e2b commit 870c782

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/connection.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ function Connection(options = {}) {
2424
let id = 1
2525
let ended
2626
let ready = false
27+
let statements = {}
2728

2829
const queries = Queue()
29-
, statements = new Map()
3030
, connection = { send, end, destroy }
3131

3232
const socket = postgresSocket(options, {
@@ -52,8 +52,8 @@ function Connection(options = {}) {
5252
return connection
5353

5454
function onparse() {
55-
if (backend.query && backend.query.statement.name)
56-
statements[backend.query.statement.sig] = backend.query.statement.name
55+
if (backend.query && backend.query.statement.sig)
56+
statements[backend.query.statement.sig] = backend.query.statement
5757
}
5858

5959
function onauth(type, x) {
@@ -102,8 +102,8 @@ function Connection(options = {}) {
102102

103103
const buffer = query.simple
104104
? simple(str, query)
105-
: statements.has(sig)
106-
? prepared(statements.get(sig), args, query)
105+
: sig in statements
106+
? prepared(statements[sig], args, query)
107107
: prepare(sig, str, args, query)
108108

109109
backend.query || !ready
@@ -169,7 +169,7 @@ function Connection(options = {}) {
169169

170170
function close() {
171171
error(errors.connection('CLOSED', options))
172-
statements.clear()
172+
statements = {}
173173
ready = false
174174
}
175175

0 commit comments

Comments
 (0)