Skip to content

Commit f9db338

Browse files
committed
Don't truncate BigInts
BigInts are currently converted to JS Numbers, which can't fit values over 2**53. Fixes #259
1 parent 56bd0d9 commit f9db338

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

lib/result/ArrowResultConverter.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ export default class ArrowResultConverter implements IResultsProvider<Array<any>
205205
}
206206

207207
// Return other values as is
208-
return typeof value === 'bigint' ? Number(value) : value;
208+
return value;
209209
}
210210

211211
private convertThriftTypes(record: Record<string, any>): any {

lib/result/utils.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,11 @@ function convertJSON(value: any, defaultValue: any): any {
4949
}
5050

5151
function convertBigInt(value: any): any {
52-
if (typeof value === 'bigint') {
53-
return Number(value);
54-
}
5552
if (value instanceof Int64) {
56-
return value.toNumber();
53+
return BigInt(value.toString());
5754
}
55+
56+
// Do not convert a BigInt away from the BigInt type
5857
return value;
5958
}
6059

0 commit comments

Comments
 (0)