stacks-network/stacks-core

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

Open

#5,225 opened on 2024年9月23日

GitHub で見る
 (0 comments) (1 reaction) (0 assignees)Rust (758 forks)auto 404
good first issue

Repository metrics

Stars
 (3,063 stars)
PR merge metrics
 (PR metrics pending)

説明

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).

コントリビューターガイド