Skip to content

Commit 708cdae

Browse files
committed
Request should use this.parent not this.connection
1 parent 0de3e65 commit 708cdae

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

lib/base/request.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ class Request extends EventEmitter {
3838
this._paused = false
3939
this.parent = parent || globalConnection.pool
4040
this.parameters = {}
41+
this.stream = null
42+
this.arrayRowMode = null
4143
}
4244

4345
get paused () {
@@ -223,8 +225,8 @@ class Request extends EventEmitter {
223225
*/
224226

225227
batch (batch, callback) {
226-
if (this.stream == null && this.connection) this.stream = this.connection.config.stream
227-
if (this.arrayRowMode == null && this.connection) this.arrayRowMode = this.connection.config.arrayRowMode
228+
if (this.stream === null && this.parent) this.stream = this.parent.config.stream
229+
if (this.arrayRowMode === null && this.parent) this.arrayRowMode = this.parent.config.arrayRowMode
228230
this.rowsAffected = 0
229231

230232
if (typeof callback === 'function') {
@@ -287,11 +289,11 @@ class Request extends EventEmitter {
287289
*/
288290

289291
_batch (batch, callback) {
290-
if (!this.connection) {
292+
if (!this.parent) {
291293
return setImmediate(callback, new RequestError('No connection is specified for that request.', 'ENOCONN'))
292294
}
293295

294-
if (!this.connection.connected) {
296+
if (!this.parent.connected) {
295297
return setImmediate(callback, new ConnectionError('Connection is closed.', 'ECONNCLOSED'))
296298
}
297299

@@ -316,8 +318,8 @@ class Request extends EventEmitter {
316318
options = {}
317319
}
318320

319-
if (this.stream == null && this.connection) this.stream = this.connection.config.stream
320-
if (this.arrayRowMode == null && this.connection) this.arrayRowMode = this.connection.config.arrayRowMode
321+
if (this.stream === null && this.parent) this.stream = this.parent.config.stream
322+
if (this.arrayRowMode === null && this.parent) this.arrayRowMode = this.parent.config.arrayRowMode
321323

322324
if (this.stream || typeof callback === 'function') {
323325
this._bulk(table, options, (err, rowsAffected) => {
@@ -393,8 +395,8 @@ class Request extends EventEmitter {
393395
*/
394396

395397
query (command, callback) {
396-
if (this.stream == null && this.connection) this.stream = this.connection.config.stream
397-
if (this.arrayRowMode == null && this.connection) this.arrayRowMode = this.connection.config.arrayRowMode
398+
if (this.stream === null && this.parent) this.stream = this.parent.config.stream
399+
if (this.arrayRowMode === null && this.parent) this.arrayRowMode = this.parent.config.arrayRowMode
398400
this.rowsAffected = 0
399401

400402
if (typeof callback === 'function') {
@@ -482,8 +484,8 @@ class Request extends EventEmitter {
482484
*/
483485

484486
execute (command, callback) {
485-
if (this.stream == null && this.connection) this.stream = this.connection.config.stream
486-
if (this.arrayRowMode == null && this.connection) this.arrayRowMode = this.connection.config.arrayRowMode
487+
if (this.stream === null && this.parent) this.stream = this.parent.config.stream
488+
if (this.arrayRowMode === null && this.parent) this.arrayRowMode = this.parent.config.arrayRowMode
487489
this.rowsAffected = 0
488490

489491
if (typeof callback === 'function') {

0 commit comments

Comments
 (0)