@@ -61,7 +61,7 @@ p.submit = function(connection) {
6161 } ;
6262
6363 var onReadyForQuery = function ( ) {
64- //remove all listeners
64+ //remove all listeners
6565 connection . removeListener ( 'rowDescription' , handleRowDescription ) ;
6666 connection . removeListener ( 'dataRow' , handleDatarow ) ;
6767 connection . removeListener ( 'readyForQuery' , onReadyForQuery ) ;
@@ -110,29 +110,28 @@ p.prepare = function(connection) {
110110 name : self . name || ""
111111 } ) ;
112112
113- //TODO test for & support multpile row requests
114- connection . execute ( {
115- portal : self . name ,
116- rows : self . rows
117- } ) ;
113+ var getRows = function ( ) {
114+ connection . execute ( {
115+ portal : self . name ,
116+ rows : self . rows
117+ } ) ;
118+ connection . flush ( ) ;
119+ } ;
118120
119- connection . flush ( ) ;
121+ getRows ( ) ;
120122
121123 //TODO support EmptyQueryResponse, ErrorResponse, and PortalSuspended
122124 var onCommandComplete = function ( ) {
123- connection . removeListener ( 'error' , onError ) ;
125+ connection . removeListener ( 'error' , onCommandComplete ) ;
124126 connection . removeListener ( 'commandComplete' , onCommandComplete ) ;
127+ connection . removeListener ( 'portalSuspended' , getRows ) ;
125128 connection . sync ( ) ;
126129 } ;
127130
128- var onError = function ( ) {
129- connection . removeListener ( 'error' , onError ) ;
130- connection . removeListener ( 'commandComplete' , onCommandComplete ) ;
131- connection . sync ( ) ;
132- } ;
131+ connection . on ( 'portalSuspended' , getRows ) ;
133132
134133 connection . on ( 'commandComplete' , onCommandComplete ) ;
135- connection . on ( 'error' , onError ) ;
134+ connection . on ( 'error' , onCommandComplete ) ;
136135} ;
137136
138137var dateParser = function ( isoDate ) {
0 commit comments