Repository navigation
feat: bind BigInt parameters as 64-bit integers - #648
Merged
Merged
Conversation
A BigInt was bound as its decimal text, so it was stored as TEXT and compared as text. Bind it with sqlite3_bind_int64 instead, and throw a RangeError for a BigInt outside the 64-bit range.
lovasoa
approved these changes
Nov 17, 2026
Member
|
useful, thanks! |
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.
A
BigIntparameter is bound as its decimal text, so it's stored as TEXT and compares as text:A query like
WHERE id = ?with aBigIntid finds nothing, andINTEGERaffinity is the only thing that turns an inserted value back into a number. A value outside the 64-bit range is stored as text too, with no error.This binds a
BigIntwithsqlite3_bind_int64, and throws aRangeErrorfor one outside the 64-bit range. The same query gives[["integer", 1]].The WebAssembly builds pass the value to C as a
BigInt. The asm.js builds can't (Emscripten turns off BigInt integration under-sWASM=0and splits an i64 into two i32 halves), so there it's passed as its low and high 32 bits. Which ABI a build has is read once at startup fromsqlite3_memory_used(), which returns an i64.Tests in
test/test_big_int.jscover small and negative values, values pastNumber.MAX_SAFE_INTEGER, both ends of the 64-bit range, both out-of-range sides, named parameters, and aWHEREmatch against a stored integer. CI on the fork passes, andtest/all.jspassestest big inton the three asm.js builds as well (issue482andnative_math_functionsfail there on 1.16.0 already).Closes #341