@@ -211,7 +211,7 @@ export class SqlResultImpl implements SqlResult {
211211
212212 isRowSet ( ) : Promise < boolean > {
213213 return this . executeDeferred . promise . then ( ( ) => {
214- return this . updateCount === Long . fromInt ( - 1 ) ;
214+ return this . rowMetadata !== null ;
215215 } ) ;
216216 }
217217
@@ -242,6 +242,7 @@ export class SqlResultImpl implements SqlResult {
242242 // Prevent ongoing/future fetch requests
243243 if ( ! this . fetchDeferred ) {
244244 this . fetchDeferred = deferredPromise < SqlPage > ( ) ;
245+ this . fetchDeferred . promise . catch ( ( ) => { } ) ;
245246 }
246247 this . fetchDeferred . reject ( error ) ;
247248 // Send the close request.
@@ -255,7 +256,10 @@ export class SqlResultImpl implements SqlResult {
255256 return this . closeDeferred . promise ;
256257 }
257258
258- /** Called when next page of the result is received. */
259+ /**
260+ * Called when next page of the result is received.
261+ * @param page
262+ */
259263 private onNextPage ( page : SqlPage ) {
260264 this . currentPage = page ;
261265 this . currentRowCount = page . getRowCount ( ) ;
@@ -267,7 +271,10 @@ export class SqlResultImpl implements SqlResult {
267271 }
268272 }
269273
270- /** Called when an error is occurred during SQL execute */
274+ /**
275+ * Called when an error is occurred during SQL execution.
276+ * @param error The wrapped error that can be propagated to the user through executeDeferred.
277+ */
271278 onExecuteError ( error : HazelcastSqlException ) : void {
272279 // Ignore the error if SQL result is closed.
273280 if ( this . closed ) {
@@ -303,18 +310,23 @@ export class SqlResultImpl implements SqlResult {
303310 }
304311 }
305312
306- /** Called when a execute response is received. */
307- onExecuteResponse ( rowMetadata : SqlRowMetadata | null , rowPage : SqlPage , updateCount : Long ) {
308- // Ignore the response if SQL result is closed.
313+ /**
314+ * Called when a execute response is received.
315+ * @param rowMetadata The row metadata. It is null if the response only contains the update count.
316+ * @param rowPage The first page of the result. It is null if the response only contains the update count.
317+ * @param updateCount The update count.
318+ */
319+ onExecuteResponse ( rowMetadata : SqlRowMetadata | null , rowPage : SqlPage | null , updateCount : Long ) {
320+ // Ignore the response if the SQL result is closed.
309321 if ( this . closed ) {
310322 return ;
311323 }
312324
313- if ( rowMetadata !== null ) { // Result that including rows
325+ if ( rowMetadata !== null ) { // Result that includes rows
314326 this . rowMetadata = rowMetadata ;
315327 this . onNextPage ( rowPage ) ;
316328 this . updateCount = Long . fromInt ( - 1 ) ;
317- } else { // Result that including update count
329+ } else { // Result that includes update count
318330 this . updateCount = updateCount ;
319331 this . closed = true ;
320332 }
@@ -333,13 +345,13 @@ export class SqlResultImpl implements SqlResult {
333345 }
334346 // Do not start a fetch if the result is already closed
335347 if ( this . closed ) {
336- return Promise . reject ( 'Cannot fetch, the result is already closed' ) ;
348+ return Promise . reject ( new IllegalStateError ( 'Cannot fetch, the result is already closed' ) ) ;
337349 }
338350
339351 this . fetchDeferred = deferredPromise < SqlPage > ( ) ;
340352
341- this . sqlService . fetch ( this . connection , this . queryId , this . cursorBufferSize ) . then ( value => {
342- this . fetchDeferred . resolve ( value ) ;
353+ this . sqlService . fetch ( this . connection , this . queryId , this . cursorBufferSize ) . then ( sqlPage => {
354+ this . fetchDeferred . resolve ( sqlPage ) ;
343355 this . fetchDeferred = undefined ; // Set fetchDeferred to undefined to be able to fetch again
344356 } ) . catch ( err => {
345357 this . fetchDeferred . reject ( this . sqlService . toHazelcastSqlException ( err , this . connection ) ) ;
@@ -350,7 +362,6 @@ export class SqlResultImpl implements SqlResult {
350362
351363 /**
352364 * Checks if there are rows to iterate in a recursive manner, similar to a non-blocking while block
353- * @internal
354365 */
355366 private checkHasNext ( ) : Promise < boolean > {
356367 if ( this . currentPosition === this . currentRowCount ) {
0 commit comments