Support 64bit numbers
Or at least provide a warning somewhere I lost some time on this.
Have you tried the int64 option? https://github.com/denodrivers/sqlite3/blob/main/doc.md#options
Sorry about that! I had been switching between different drivers without looking at their individual options. Seems like the others must've had that on by default.
This actually makes me curious though - why not have int64 enabled by default?
Previously it was slow to return bigints from Deno FFI but now it’s fast. But I’m still not sure what to do in this case: SQLite3 tells us there is a column value of int type, we don’t know if it’s 32 bit or 64 bit so we always assume 32 bit unless int64 option is specified, in which case a bigint is returned only when a value is too big to fit in JS number. So the value becomes a union number | bigint - which is not exactly ideal because bigints are not compatible with numbers and would need special handling like checking the type before it’s used with something. We have three options to default to:
- return a 32 bit truncated value as JS number
- always assume 64 bit and return a bigint
- return number if value fits in 52 bits for JS number else bigint
Another option would be to maybe always get a 64 bit value and truncate it to 52 bits for JS number, which is certainly better than 32 bit and will support majority use cases. BigInts are not a performance issue in recent Deno FFI update anymore so it won’t have any negative impacts.
I've added better documentation for this behavior and also now allow changing int64 at statement level. Closing this issue as completed for now.