mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-26 19:41:37 +08:00
Merge pull request #254 from jgallagher/add-fromsql-isize
Add FromSql/ToSql impls for isize.
This commit is contained in:
commit
83d9817905
@ -1,3 +1,7 @@
|
|||||||
|
# Version 0.10.2 (UPCOMING)
|
||||||
|
|
||||||
|
* Adds `FromSql` and `ToSql` impls for `isize`. Documents why `usize` and `u64` are not included.
|
||||||
|
|
||||||
# Version 0.10.1 (2017-03-03)
|
# Version 0.10.1 (2017-03-03)
|
||||||
|
|
||||||
* Updates the `bundled` SQLite version to 3.17.0.
|
* Updates the `bundled` SQLite version to 3.17.0.
|
||||||
|
@ -49,6 +49,14 @@ impl Error for FromSqlError {
|
|||||||
pub type FromSqlResult<T> = Result<T, FromSqlError>;
|
pub type FromSqlResult<T> = Result<T, FromSqlError>;
|
||||||
|
|
||||||
/// A trait for types that can be created from a SQLite value.
|
/// A trait for types that can be created from a SQLite value.
|
||||||
|
///
|
||||||
|
/// Note that `FromSql` and `ToSql` are defined for most integral types, but not `u64` or `usize`.
|
||||||
|
/// This is intentional; SQLite returns integers as signed 64-bit values, which cannot fully
|
||||||
|
/// represent the range of these types. Rusqlite would have to decide how to handle negative
|
||||||
|
/// values: return an error or reinterpret as a very large postive numbers, neither of which is
|
||||||
|
/// guaranteed to be correct for everyone. Callers can work around this by fetching values as i64
|
||||||
|
/// and then doing the interpretation themselves or by defining a newtype and implementing
|
||||||
|
/// `FromSql`/`ToSql` for it.
|
||||||
pub trait FromSql: Sized {
|
pub trait FromSql: Sized {
|
||||||
fn column_result(value: ValueRef) -> FromSqlResult<Self>;
|
fn column_result(value: ValueRef) -> FromSqlResult<Self>;
|
||||||
}
|
}
|
||||||
@ -72,6 +80,7 @@ macro_rules! from_sql_integral(
|
|||||||
from_sql_integral!(i8);
|
from_sql_integral!(i8);
|
||||||
from_sql_integral!(i16);
|
from_sql_integral!(i16);
|
||||||
from_sql_integral!(i32);
|
from_sql_integral!(i32);
|
||||||
|
from_sql_integral!(isize);
|
||||||
from_sql_integral!(u8);
|
from_sql_integral!(u8);
|
||||||
from_sql_integral!(u16);
|
from_sql_integral!(u16);
|
||||||
from_sql_integral!(u32);
|
from_sql_integral!(u32);
|
||||||
|
@ -74,6 +74,7 @@ to_sql_self!(i8);
|
|||||||
to_sql_self!(i16);
|
to_sql_self!(i16);
|
||||||
to_sql_self!(i32);
|
to_sql_self!(i32);
|
||||||
to_sql_self!(i64);
|
to_sql_self!(i64);
|
||||||
|
to_sql_self!(isize);
|
||||||
to_sql_self!(u8);
|
to_sql_self!(u8);
|
||||||
to_sql_self!(u16);
|
to_sql_self!(u16);
|
||||||
to_sql_self!(u32);
|
to_sql_self!(u32);
|
||||||
|
@ -43,6 +43,7 @@ macro_rules! from_i64(
|
|||||||
from_i64!(i8);
|
from_i64!(i8);
|
||||||
from_i64!(i16);
|
from_i64!(i16);
|
||||||
from_i64!(i32);
|
from_i64!(i32);
|
||||||
|
from_i64!(isize);
|
||||||
from_i64!(u8);
|
from_i64!(u8);
|
||||||
from_i64!(u16);
|
from_i64!(u16);
|
||||||
from_i64!(u32);
|
from_i64!(u32);
|
||||||
|
Loading…
Reference in New Issue
Block a user