Comparing version 2.7.1 to 2.7.3
20
index.js
@@ -89,2 +89,4 @@ 'use strict' | ||
_closePortal() { | ||
if (this.state === 'done') return | ||
// because we opened a named portal to stream results | ||
@@ -101,2 +103,4 @@ // we need to close the same named portal. Leaving a named portal | ||
} | ||
this.state = 'done' | ||
} | ||
@@ -213,16 +217,10 @@ | ||
if (!this.connection || this.state === 'done') { | ||
if (cb) { | ||
return setImmediate(cb) | ||
} else { | ||
return | ||
} | ||
setImmediate(cb) | ||
return promise | ||
} | ||
this._closePortal() | ||
this.state = 'done' | ||
if (cb) { | ||
this.connection.once('readyForQuery', function () { | ||
cb() | ||
}) | ||
} | ||
this.connection.once('readyForQuery', function () { | ||
cb() | ||
}) | ||
@@ -229,0 +227,0 @@ // Return the promise (or undefined) |
{ | ||
"name": "pg-cursor", | ||
"version": "2.7.1", | ||
"version": "2.7.3", | ||
"description": "Query cursor extension for node-postgres", | ||
@@ -21,3 +21,3 @@ "main": "index.js", | ||
"mocha": "^7.1.2", | ||
"pg": "^8.7.1" | ||
"pg": "^8.7.3" | ||
}, | ||
@@ -27,3 +27,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "92b4d37926c276d343bfe56447ff6f526af757cf" | ||
"gitHead": "4fa7ee891a456168a75695ac026792136f16577f" | ||
} |
@@ -26,2 +26,13 @@ const assert = require('assert') | ||
it('can close a finished cursor a promise', function (done) { | ||
const cursor = new Cursor(text) | ||
this.client.query(cursor) | ||
cursor.read(100, (err) => { | ||
assert.ifError(err) | ||
cursor.close().then(() => { | ||
this.client.query('SELECT NOW()', done) | ||
}) | ||
}) | ||
}) | ||
it('closes cursor early', function (done) { | ||
@@ -28,0 +39,0 @@ const cursor = new Cursor(text) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26143
762