Skip to content

Commit aa2961c

Browse files
committed
fix(pg): run a named statement with an empty text more than once on the native client too
1 parent b97070a commit aa2961c

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎packages/pg/lib/native/query.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,9 @@ NativeQuery.prototype.submit = function (client) {
136136
const values = (this.values || []).map(utils.prepareValue)
137137

138138
// check if the client has already executed this named query
139-
// if so...just execute it again - skip the planning phase
140-
if (client.namedQueries[this.name]) {
139+
// if so...just execute it again - skip the planning phase. By presence, not truth: a
140+
// named statement with an empty text is prepared all the same
141+
if (client.namedQueries[this.name] !== undefined) {
141142
if (this.text && client.namedQueries[this.name] !== this.text) {
142143
const err = new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`)
143144
return after(err)

0 commit comments

Comments
 (0)