File tree 2 files changed +8
-4
lines changed
2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ const util = require('util')
6
6
7
7
let nextUniqueID = 1 // concept borrowed from org.postgresql.core.v3.QueryExecutorImpl
8
8
9
- function Cursor ( text , values , config ) {
9
+ function Cursor ( text , values , config ) {
10
10
EventEmitter . call ( this )
11
11
12
12
this . _conf = config || { }
@@ -192,7 +192,7 @@ Cursor.prototype.close = function (cb) {
192
192
this . _closePortal ( )
193
193
this . state = 'done'
194
194
if ( cb ) {
195
- this . connection . once ( 'closeComplete ' , function ( ) {
195
+ this . connection . once ( 'readyForQuery ' , function ( ) {
196
196
cb ( )
197
197
} )
198
198
}
Original file line number Diff line number Diff line change @@ -7,7 +7,10 @@ describe('close', function () {
7
7
beforeEach ( function ( done ) {
8
8
const client = ( this . client = new pg . Client ( ) )
9
9
client . connect ( done )
10
- client . on ( 'drain' , client . end . bind ( client ) )
10
+ } )
11
+
12
+ this . afterEach ( function ( done ) {
13
+ this . client . end ( done )
11
14
} )
12
15
13
16
it ( 'can close a finished cursor without a callback' , function ( done ) {
@@ -34,8 +37,9 @@ describe('close', function () {
34
37
const cursor = new Cursor ( text )
35
38
const client = this . client
36
39
client . query ( cursor )
37
- cursor . read ( 25 , function ( err ) {
40
+ cursor . read ( 25 , function ( err , rows ) {
38
41
assert . ifError ( err )
42
+ assert . strictEqual ( rows . length , 25 )
39
43
cursor . close ( function ( err ) {
40
44
assert . ifError ( err )
41
45
client . query ( 'SELECT NOW()' , done )
You can’t perform that action at this time.
0 commit comments