WiseLibs / better-sqlite3

The fastest and simplest library for SQLite3 in Node.js.
MIT License
5.46k stars 396 forks source link

Mixing integers and bigints in when getting data #1031

Closed terrablue closed 1 year ago

terrablue commented 1 year ago

Hi, according to https://github.com/WiseLibs/better-sqlite3/blob/master/docs/integer.md#getting-bigints-from-the-database, it is possible to get integers as bigints, either per db or per statement.

In my use case, I have a mixed table of numbers and bigints. That is, some columns should map to JavaScript bigints and some to normal numbers. Is it possible to add that?

My current solution is getting everything as bigints, and calling Number() on columns designated as normal numbers by my ORM, but it's kind of hacky.

JoshuaWise commented 1 year ago

This would be a tricky feature to get right because table columns can be added, removed, or changed while a prepared statement is still alive. Because of this, it probably wouldn't be possible to optimize it much, so it wouldn't be any more efficient to implement it in better-sqlite3 compared to implementing it in a user-land library/ORM.