Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

u64: Some thoughts. #3

Open
trevyn opened this issue Jan 12, 2021 · 0 comments
Open

u64: Some thoughts. #3

trevyn opened this issue Jan 12, 2021 · 0 comments

Comments

@trevyn
Copy link
Owner

trevyn commented Jan 12, 2021

This is the error message if you try to Turbosql a u64:

SQLite cannot natively store unsigned 64-bit integers, so Turbosql does not support u64 fields. Use i64, u32, f64, or a string or binary format instead.

rusqlite provides an interesting feature i128_blob:

i128_blob allows storing values of type i128 type in SQLite databases. Internally, the data is stored as a 16 byte big-endian blob, with the most significant bit flipped, which allows ordering and comparison between different blobs storing i128s to work as expected.

So it would be possible to support i128_blob in Turbosql too, and support u64 mapped in this same way to a SQLite BLOB. This would definitely have to be gated behind an opt-in feature (u64_i128_as_blob?) to make clear that these two primitive numeric datatypes in Rust will behave differently than the others from SQLite's perspective. (BLOB serial type code vs an integer serial type code: https://sqlite.org/fileformat.html#record_format ) This would also affect any external software that might want to read the data from the .sqlite file.

@trevyn trevyn changed the title Some thoughts about u64 u64: Some thoughts. Jan 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant