Skip to content

Commit

Permalink
fix(client): improve big int parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
alonsovb committed Dec 19, 2024
1 parent b9ed52f commit 797f9af
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion presto-client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@ import {
} from './types'

function digitsToBigInt(_: string, value: unknown, { source }: { source: string }) {
return /^\d+$/.test(source) ? BigInt(source) : value
// Ignore non-numbers
if (typeof value !== 'number') return value

// If not an integer, use the value
// TODO: Check if Presto can return floats that could also lose precision
if (!Number.isInteger(value)) return value

// If number is a safe integer, we can use it
if (Number.isSafeInteger(value)) return value

return BigInt(source)
}

export class PrestoClient {
Expand Down

0 comments on commit 797f9af

Please sign in to comment.