mirror of
https://github.com/isar/rusqlite.git
synced 2025-09-15 12:12:18 +08:00
Add a feature for storing i128 as blobs.
This is behind the `i128_blob` feature. Blobs are stored as 16 byte big-endian values, with their most significant bit flipped. This is so that sorting, comparison, etc all work properly, even with negative numbers. This also allows the representation to be stable across different computers. It's possible that the `FromSql` implementation should handle the case that the real value is stored in an integer. I didn't do this, but would be willing to make the change. I don't think we should store them this way though, since I don't think users would be able to sort/compare them sanely. Support for `u128` is not implemented, as comparison with i128 values would work strangely. This also is consistent with `u64` not being allowed, not that I think that would be reason enough on it's own. The `byteorder` crate is used if this feature is flipped, as it's quite small and implements things more or less optimally. If/when `i128::{to,from}_be_bytes` gets stabilized (https://github.com/rust-lang/rust/issues/52963), we should probably use that instead.
This commit is contained in:
@@ -98,6 +98,7 @@ features](https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-s
|
||||
* `vtab` for [virtual table](https://sqlite.org/vtab.html) support (allows you to write virtual table implemntations in Rust). Currently, only read-only virtual tables are supported.
|
||||
* [`csvtab`](https://sqlite.org/csv.html), CSV virtual table written in Rust.
|
||||
* [`array`](https://sqlite.org/carray.html), The `rarray()` Table-Valued Function.
|
||||
* `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.
|
||||
|
||||
## Notes on building rusqlite and libsqlite3-sys
|
||||
|
||||
|
Reference in New Issue
Block a user