Skip to content

Commit

Permalink
Don't truncate BigInts
Browse files Browse the repository at this point in the history
BigInts are currently converted to JS Numbers, which can't fit values
over 2**53.

Fixes #259
  • Loading branch information
gabegorelick committed Oct 25, 2024
1 parent 56bd0d9 commit fe9df56
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/result/ArrowResultConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export default class ArrowResultConverter implements IResultsProvider<Array<any>
}

// Return other values as is
return typeof value === 'bigint' ? Number(value) : value;
return value;
}

private convertThriftTypes(record: Record<string, any>): any {
Expand Down
8 changes: 1 addition & 7 deletions lib/result/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Int64 from 'node-int64';
import {
Schema,
Field,
Expand Down Expand Up @@ -49,12 +48,7 @@ function convertJSON(value: any, defaultValue: any): any {
}

function convertBigInt(value: any): any {
if (typeof value === 'bigint') {
return Number(value);
}
if (value instanceof Int64) {
return value.toNumber();
}
// Do not convert a BigInt away from the BigInt type
return value;
}

Expand Down

0 comments on commit fe9df56

Please sign in to comment.