1- import { stringify , NIL , parse } from 'uuid' ;
1+ import { stringify , NIL } from 'uuid' ;
22import IOperation , {
33 FetchOptions ,
44 FinishedOptions ,
@@ -88,11 +88,12 @@ export default class DBSQLOperation implements IOperation {
8888 useOnlyPrefetchedResults ,
8989 ) ;
9090 this . closeOperation = directResults ?. closeOperation ;
91- this . context . getLogger ( ) . log ( LogLevel . debug , `Operation created with id: ${ this . getId ( ) } ` ) ;
91+ this . context . getLogger ( ) . log ( LogLevel . debug , `Operation created with id: ${ this . id } ` ) ;
9292 }
9393
94- public getId ( ) {
95- return stringify ( this . operationHandle ?. operationId ?. guid || parse ( NIL ) ) ;
94+ public get id ( ) {
95+ const operationId = this . operationHandle ?. operationId ?. guid ;
96+ return operationId ? stringify ( operationId ) : NIL ;
9697 }
9798
9899 /**
@@ -119,7 +120,7 @@ export default class DBSQLOperation implements IOperation {
119120 const chunk = await this . fetchChunk ( fetchChunkOptions ) ;
120121 data . push ( chunk ) ;
121122 } while ( await this . hasMoreRows ( ) ) ; // eslint-disable-line no-await-in-loop
122- this . context . getLogger ( ) . log ( LogLevel . debug , `Fetched all data from operation with id: ${ this . getId ( ) } ` ) ;
123+ this . context . getLogger ( ) . log ( LogLevel . debug , `Fetched all data from operation with id: ${ this . id } ` ) ;
123124
124125 return data . flat ( ) ;
125126 }
@@ -173,7 +174,7 @@ export default class DBSQLOperation implements IOperation {
173174 . getLogger ( )
174175 . log (
175176 LogLevel . debug ,
176- `Fetched chunk of size: ${ options ?. maxRows || defaultMaxRows } from operation with id: ${ this . getId ( ) } ` ,
177+ `Fetched chunk of size: ${ options ?. maxRows || defaultMaxRows } from operation with id: ${ this . id } ` ,
177178 ) ;
178179 return result ;
179180 }
@@ -185,7 +186,7 @@ export default class DBSQLOperation implements IOperation {
185186 */
186187 public async status ( progress : boolean = false ) : Promise < TGetOperationStatusResp > {
187188 await this . failIfClosed ( ) ;
188- this . context . getLogger ( ) . log ( LogLevel . debug , `Fetching status for operation with id: ${ this . getId ( ) } ` ) ;
189+ this . context . getLogger ( ) . log ( LogLevel . debug , `Fetching status for operation with id: ${ this . id } ` ) ;
189190
190191 if ( this . operationStatus ) {
191192 return this . operationStatus ;
@@ -209,7 +210,7 @@ export default class DBSQLOperation implements IOperation {
209210 return Status . success ( ) ;
210211 }
211212
212- this . context . getLogger ( ) . log ( LogLevel . debug , `Cancelling operation with id: ${ this . getId ( ) } ` ) ;
213+ this . context . getLogger ( ) . log ( LogLevel . debug , `Cancelling operation with id: ${ this . id } ` ) ;
213214
214215 const driver = await this . context . getDriver ( ) ;
215216 const response = await driver . cancelOperation ( {
@@ -233,7 +234,7 @@ export default class DBSQLOperation implements IOperation {
233234 return Status . success ( ) ;
234235 }
235236
236- this . context . getLogger ( ) . log ( LogLevel . debug , `Closing operation with id: ${ this . getId ( ) } ` ) ;
237+ this . context . getLogger ( ) . log ( LogLevel . debug , `Closing operation with id: ${ this . id } ` ) ;
237238
238239 const driver = await this . context . getDriver ( ) ;
239240 const response =
@@ -274,7 +275,7 @@ export default class DBSQLOperation implements IOperation {
274275
275276 await this . waitUntilReady ( options ) ;
276277
277- this . context . getLogger ( ) . log ( LogLevel . debug , `Fetching schema for operation with id: ${ this . getId ( ) } ` ) ;
278+ this . context . getLogger ( ) . log ( LogLevel . debug , `Fetching schema for operation with id: ${ this . id } ` ) ;
278279 const metadata = await this . fetchMetadata ( ) ;
279280 return metadata . schema ?? null ;
280281 }
0 commit comments