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

Use FromSql and ToSql implementations for u64 #5225

Open
kantai opened this issue Sep 23, 2024 · 0 comments
Open

Use FromSql and ToSql implementations for u64 #5225

kantai opened this issue Sep 23, 2024 · 0 comments
Labels
good first issue Appropriate for a new open source contribution.

Comments

@kantai
Copy link
Member

kantai commented Sep 23, 2024

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

@kantai kantai added the good first issue Appropriate for a new open source contribution. label Sep 23, 2024
@saralab saralab added this to the Nakamoto-3.0.x milestone Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Appropriate for a new open source contribution.
Projects
Status: Status: 🆕 New
Development

No branches or pull requests

2 participants