stacks-network/stacks-core

Use `FromSql` and `ToSql` implementations for `u64`

Open

#5.225 geöffnet am 23. Sept. 2024

Auf GitHub ansehen
 (0 Kommentare) (1 Reaktion) (0 zugewiesene Personen)Rust (758 Forks)auto 404
good first issue

Repository-Metriken

Stars
 (3.063 Stars)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

I discovered while reviewing #5153 that after updating rusqlite in this repo from 0.24.2 to 0.31.0, rusqlite added FromSql and ToSql impls for u64!

This implementation behaves as we would want: if a u64 is supplied which is greater than an i64::max, it returns an error, and if ToSql gets an i64 less than 0, it errors. Docs link:

ToSql and FromSql are implemented for all primitive number types. FromSql has different behaviour depending on the SQL and Rust types, and the value.

INTEGER to integer: returns an Error::IntegralValueOutOfRange error if the value does not fit in the Rust type.

... ToSql always succeeds except when storing a u64 or usize value that cannot fit in an INTEGER (i64). Also note that SQLite ignores column types, so if you store an i64 in a column with type REAL it will be stored as an INTEGER, not a REAL (unless the column is part of a STRICT table).

Contributor Guide