Merge remote-tracking branch 'origin/master' into fix-duplicated-constants

This commit is contained in:
John Gallagher 2017-04-05 13:10:48 -04:00
commit 61eb843c6b
4 changed files with 12 additions and 0 deletions

View File

@ -1,6 +1,7 @@
# Version 0.10.2 (UPCOMING) # Version 0.10.2 (UPCOMING)
* Avoid publicly exporting SQLite constants multiple times from libsqlite3-sys. * Avoid publicly exporting SQLite constants multiple times from libsqlite3-sys.
* 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)

View File

@ -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);

View File

@ -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);

View File

@ -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);