From fe9df567923e57bab35064fda63d8e27b5ef28c6 Mon Sep 17 00:00:00 2001 From: Gabe Gorelick Date: Fri, 25 Oct 2024 17:09:24 -0400 Subject: [PATCH] Don't truncate BigInts BigInts are currently converted to JS Numbers, which can't fit values over 2**53. Fixes #259 --- lib/result/ArrowResultConverter.ts | 2 +- lib/result/utils.ts | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/result/ArrowResultConverter.ts b/lib/result/ArrowResultConverter.ts index 57fa02a..b4f36fe 100644 --- a/lib/result/ArrowResultConverter.ts +++ b/lib/result/ArrowResultConverter.ts @@ -205,7 +205,7 @@ export default class ArrowResultConverter implements IResultsProvider } // Return other values as is - return typeof value === 'bigint' ? Number(value) : value; + return value; } private convertThriftTypes(record: Record): any { diff --git a/lib/result/utils.ts b/lib/result/utils.ts index 4bbdf41..81a44d8 100644 --- a/lib/result/utils.ts +++ b/lib/result/utils.ts @@ -1,4 +1,3 @@ -import Int64 from 'node-int64'; import { Schema, Field, @@ -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; }