pg 7.8.1 → 7.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -67,7 +67,7 @@ The causes and solutions to common errors can be found among the [Frequently Ask
67
67
 
68
68
  ## License
69
69
 
70
- Copyright (c) 2010-2018 Brian Carlson (brian.m.carlson@gmail.com)
70
+ Copyright (c) 2010-2019 Brian Carlson (brian.m.carlson@gmail.com)
71
71
 
72
72
  Permission is hereby granted, free of charge, to any person obtaining a copy
73
73
  of this software and associated documentation files (the "Software"), to deal
package/lib/client.js CHANGED
@@ -276,7 +276,7 @@ Client.prototype._attachListeners = function (con) {
276
276
  // it again on the same client
277
277
  con.on('parseComplete', function (msg) {
278
278
  if (self.activeQuery.name) {
279
- con.parsedStatements[self.activeQuery.name] = true
279
+ con.parsedStatements[self.activeQuery.name] = self.activeQuery.text
280
280
  }
281
281
  })
282
282
 
@@ -139,12 +139,16 @@ NativeQuery.prototype.submit = function (client) {
139
139
  // check if the client has already executed this named query
140
140
  // if so...just execute it again - skip the planning phase
141
141
  if (client.namedQueries[this.name]) {
142
+ if (this.text && client.namedQueries[this.name] !== this.text) {
143
+ const err = new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`)
144
+ return after(err)
145
+ }
142
146
  return client.native.execute(this.name, values, after)
143
147
  }
144
148
  // plan the named query the first time, then execute it
145
149
  return client.native.prepare(this.name, this.text, values.length, function (err) {
146
150
  if (err) return after(err)
147
- client.namedQueries[self.name] = true
151
+ client.namedQueries[self.name] = self.text
148
152
  return self.native.execute(self.name, values, after)
149
153
  })
150
154
  } else if (this.values) {
package/lib/query.js CHANGED
@@ -148,6 +148,10 @@ Query.prototype.submit = function (connection) {
148
148
  if (typeof this.text !== 'string' && typeof this.name !== 'string') {
149
149
  return new Error('A query must have either text or a name. Supplying neither is unsupported.')
150
150
  }
151
+ const previous = connection.parsedStatements[this.name]
152
+ if (this.text && previous && this.text !== previous) {
153
+ return new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`)
154
+ }
151
155
  if (this.values && !Array.isArray(this.values)) {
152
156
  return new Error('Query values must be an array')
153
157
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pg",
3
- "version": "7.8.1",
3
+ "version": "7.8.2",
4
4
  "description": "PostgreSQL client - pure javascript & libpq with the same API",
5
5
  "keywords": [
6
6
  "database",