1
- import { stringify , NIL , parse } from 'uuid' ;
1
+ import { stringify , NIL } from 'uuid' ;
2
2
import IOperation , {
3
3
FetchOptions ,
4
4
FinishedOptions ,
@@ -88,11 +88,12 @@ export default class DBSQLOperation implements IOperation {
88
88
useOnlyPrefetchedResults ,
89
89
) ;
90
90
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 } ` ) ;
92
92
}
93
93
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 ;
96
97
}
97
98
98
99
/**
@@ -119,7 +120,7 @@ export default class DBSQLOperation implements IOperation {
119
120
const chunk = await this . fetchChunk ( fetchChunkOptions ) ;
120
121
data . push ( chunk ) ;
121
122
} 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 } ` ) ;
123
124
124
125
return data . flat ( ) ;
125
126
}
@@ -173,7 +174,7 @@ export default class DBSQLOperation implements IOperation {
173
174
. getLogger ( )
174
175
. log (
175
176
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 } ` ,
177
178
) ;
178
179
return result ;
179
180
}
@@ -185,7 +186,7 @@ export default class DBSQLOperation implements IOperation {
185
186
*/
186
187
public async status ( progress : boolean = false ) : Promise < TGetOperationStatusResp > {
187
188
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 } ` ) ;
189
190
190
191
if ( this . operationStatus ) {
191
192
return this . operationStatus ;
@@ -209,7 +210,7 @@ export default class DBSQLOperation implements IOperation {
209
210
return Status . success ( ) ;
210
211
}
211
212
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 } ` ) ;
213
214
214
215
const driver = await this . context . getDriver ( ) ;
215
216
const response = await driver . cancelOperation ( {
@@ -233,7 +234,7 @@ export default class DBSQLOperation implements IOperation {
233
234
return Status . success ( ) ;
234
235
}
235
236
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 } ` ) ;
237
238
238
239
const driver = await this . context . getDriver ( ) ;
239
240
const response =
@@ -274,7 +275,7 @@ export default class DBSQLOperation implements IOperation {
274
275
275
276
await this . waitUntilReady ( options ) ;
276
277
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 } ` ) ;
278
279
const metadata = await this . fetchMetadata ( ) ;
279
280
return metadata . schema ?? null ;
280
281
}
0 commit comments