feat: accept BigInt values in intColumn() - #63
Open
PedroHenrique0713 wants to merge 1 commit into
Open
Conversation
QuestDB's LONG is a 64-bit signed integer, which is wider than the safe integer range of JavaScript's number. Passing a LONG above Number.MAX_SAFE_INTEGER silently lost precision before it ever reached the buffer. intColumn() now takes number | bigint, keeping number for backwards compatibility, and validates the same way timestampColumn() already does for its number | bigint parameter. value.toString() already renders a BigInt without the trailing n, so the ILP line is unchanged in shape. The error message for a non-integer changes to mention BigInt, matching the wording timestampColumn() uses; the existing test for it is updated.
PedroHenrique0713
force-pushed
the
feat/int-column-bigint
branch
from
September 1, 2026 03:15
56da9c5 to
a9aecfb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #58.
Picking this up since it has been open since February and @saibotsivad, who offered to send a PR, has not had the chance. Happy to step aside if they would rather land it themselves.
Implements exactly the signature @glasstiger asked for in the issue thread:
numberis kept for backwards compatibility.Why
QuestDB's
LONGis a 64-bit signed integer. JavaScript'snumberis a double, so anything aboveNumber.MAX_SAFE_INTEGER(9007199254740991) is already rounded by the time it reachesintColumn()— the loss happens at the call site and nothing downstream can detect it. There was no way to write a full-rangeLONGfrom this client.What changed
src/buffer/base.ts—intColumn()takesnumber | bigint, validated the same waytimestampColumn()already validates its ownnumber | bigintparameter:typeof value !== "bigint" && !Number.isInteger(value).src/buffer/index.tsandsrc/sender.ts— signatures and JSDoc.The wire format is unchanged:
value.toString()renders a BigInt without the trailingn, so the ILP line is identical for a value expressible both ways.Tests
Two new cases in
test/sender.buffer.test.ts:9223372036854775807n(2^63-1, the largestLONG) survives the round trip. As anumberit rounds to 9223372036854775808, which is out of range for the columnOne existing test is updated: the non-integer error message now mentions BigInt, matching the wording
timestampColumn()uses.vitestpasses locally,eslintandprettier --checkare clean.tsc --noEmitreports one pre-existing error about conflictingundiciFormData types, unchanged by this branch (same count on a clean checkout).