File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 1- 18.17.1
1+ 21.0.0
Original file line number Diff line number Diff line change @@ -9,6 +9,10 @@ import {
99 Table ,
1010} from './types'
1111
12+ function digitsToBigInt ( _ : string , value : unknown , { source } : { source : string } ) {
13+ return / ^ \d + $ / . test ( source ) ? BigInt ( source ) : value
14+ }
15+
1216export class PrestoClient {
1317 private baseUrl : string
1418 private catalog ?: string
@@ -270,7 +274,7 @@ export class PrestoClient {
270274 throw new Error ( `Query failed: ${ JSON . stringify ( await response . text ( ) ) } ` )
271275 }
272276
273- const prestoResponse = ( await response . json ( ) ) as PrestoResponse
277+ const prestoResponse = ( await this . prestoConversionToJSON ( { response } ) ) as PrestoResponse
274278 if ( ! prestoResponse ) {
275279 throw new Error ( `Query failed with an empty response from the server.` )
276280 }
@@ -334,6 +338,13 @@ export class PrestoClient {
334338 method,
335339 } )
336340 }
341+
342+ private async prestoConversionToJSON ( { response } : { response : Response } ) : Promise < unknown > {
343+ const text = await response . text ( )
344+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
345+ // @ts -ignore JSON.parse with a 3 argument reviver is a stage 3 proposal with some support, allow it here.
346+ return JSON . parse ( text , digitsToBigInt )
347+ }
337348}
338349
339350export default PrestoClient
You can’t perform that action at this time.
0 commit comments