File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
Expand file tree Collapse file tree 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')
66
77let nextUniqueID = 1 // concept borrowed from org.postgresql.core.v3.QueryExecutorImpl
88
9- function Cursor ( text , values , config ) {
9+ function Cursor ( text , values , config ) {
1010 EventEmitter . call ( this )
1111
1212 this . _conf = config || { }
@@ -192,7 +192,7 @@ Cursor.prototype.close = function (cb) {
192192 this . _closePortal ( )
193193 this . state = 'done'
194194 if ( cb ) {
195- this . connection . once ( 'closeComplete ' , function ( ) {
195+ this . connection . once ( 'readyForQuery ' , function ( ) {
196196 cb ( )
197197 } )
198198 }
Original file line number Diff line number Diff line change @@ -7,7 +7,10 @@ describe('close', function () {
77 beforeEach ( function ( done ) {
88 const client = ( this . client = new pg . Client ( ) )
99 client . connect ( done )
10- client . on ( 'drain' , client . end . bind ( client ) )
10+ } )
11+
12+ this . afterEach ( function ( done ) {
13+ this . client . end ( done )
1114 } )
1215
1316 it ( 'can close a finished cursor without a callback' , function ( done ) {
@@ -34,8 +37,9 @@ describe('close', function () {
3437 const cursor = new Cursor ( text )
3538 const client = this . client
3639 client . query ( cursor )
37- cursor . read ( 25 , function ( err ) {
40+ cursor . read ( 25 , function ( err , rows ) {
3841 assert . ifError ( err )
42+ assert . strictEqual ( rows . length , 25 )
3943 cursor . close ( function ( err ) {
4044 assert . ifError ( err )
4145 client . query ( 'SELECT NOW()' , done )
You can’t perform that action at this time.
0 commit comments