Store BigInt as SQLite integer? #17980
Unanswered
snoggles
asked this question in
Help & Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
I have a large number of discord snowflakes (i.e. BigInt) to store in SQLite via Sequelize. I'd like to store them as 8-byte integers rather than 18-byte strings, but I'm running up against #17154.
Attempted Solution
Defining the following mapping results in precision loss. The conversion to JS number (non-BigInt) happens before my mapping is invoked.
SQLite Dialect Mappings?
The following line from https://sequelize.org/docs/v6/other-topics/extending-data-types/ seems relevant:
However, it only shows postgres mappings--no SQLite. Both Claude Code and I are at a loss to figure out correct SQLite mappings.
Rejected Alternatives
I don't want to run a separate database service for this.
I don't want to store the values as opaque BLOBs that I cannot inspect in the DB.
Context
https://github.com/snoggles/loggles/blob/main/src/db/snowflake.js (currently using strings, sadly)
Guidance Request
Are there existing examples of storing BigInts as SQLite numbers--or at least using sequelize to create SQLite dialect mappings? Are SQLite dialect mappings the correct solution?
Beta Was this translation helpful? Give feedback.
All reactions