mirror of
https://github.com/isar/rusqlite.git
synced 2025-09-16 20:52:19 +08:00
Merge branch 'master' into safe-tosql
This commit is contained in:
22
src/lib.rs
22
src/lib.rs
@@ -50,8 +50,6 @@
|
||||
//! }
|
||||
//! }
|
||||
//! ```
|
||||
#![cfg_attr(feature="clippy", feature(plugin))]
|
||||
#![cfg_attr(feature="clippy", plugin(clippy))]
|
||||
|
||||
extern crate libc;
|
||||
extern crate libsqlite3_sys as ffi;
|
||||
@@ -105,6 +103,7 @@ mod raw_statement;
|
||||
const STATEMENT_CACHE_DEFAULT_CAPACITY: usize = 16;
|
||||
|
||||
/// Old name for `Result`. `SqliteResult` is deprecated.
|
||||
#[deprecated(since = "0.6.0", note = "Use Result instead")]
|
||||
pub type SqliteResult<T> = Result<T>;
|
||||
|
||||
/// A typedef of the result returned by many methods.
|
||||
@@ -151,6 +150,7 @@ impl<'a> DatabaseName<'a> {
|
||||
}
|
||||
|
||||
/// Old name for `Connection`. `SqliteConnection` is deprecated.
|
||||
#[deprecated(since = "0.6.0", note = "Use Connection instead")]
|
||||
pub type SqliteConnection = Connection;
|
||||
|
||||
/// A connection to a SQLite database.
|
||||
@@ -367,6 +367,7 @@ impl Connection {
|
||||
///
|
||||
/// This method should be considered deprecated. Use `query_row` instead, which now
|
||||
/// does exactly the same thing.
|
||||
#[deprecated(since = "0.1.0", note = "Use query_row instead")]
|
||||
pub fn query_row_safe<T, F>(&self, sql: &str, params: &[&ToSql], f: F) -> Result<T>
|
||||
where F: FnOnce(Row) -> T
|
||||
{
|
||||
@@ -507,6 +508,7 @@ struct InnerConnection {
|
||||
}
|
||||
|
||||
/// Old name for `OpenFlags`. `SqliteOpenFlags` is deprecated.
|
||||
#[deprecated(since = "0.6.0", note = "Use OpenFlags instead")]
|
||||
pub type SqliteOpenFlags = OpenFlags;
|
||||
|
||||
bitflags! {
|
||||
@@ -678,6 +680,7 @@ impl Drop for InnerConnection {
|
||||
}
|
||||
|
||||
/// Old name for `Statement`. `SqliteStatement` is deprecated.
|
||||
#[deprecated(since = "0.6.0", note = "Use Statement instead")]
|
||||
pub type SqliteStatement<'conn> = Statement<'conn>;
|
||||
|
||||
/// A prepared statement.
|
||||
@@ -1013,6 +1016,7 @@ impl<'stmt, T, E, F> Iterator for AndThenRows<'stmt, F>
|
||||
}
|
||||
|
||||
/// Old name for `Rows`. `SqliteRows` is deprecated.
|
||||
#[deprecated(since = "0.6.0", note = "Use Rows instead")]
|
||||
pub type SqliteRows<'stmt> = Rows<'stmt>;
|
||||
|
||||
/// An handle for the resulting rows of a query.
|
||||
@@ -1077,6 +1081,7 @@ impl<'stmt> Drop for Rows<'stmt> {
|
||||
}
|
||||
|
||||
/// Old name for `Row`. `SqliteRow` is deprecated.
|
||||
#[deprecated(since = "0.6.0", note = "Use Row instead")]
|
||||
pub type SqliteRow<'a, 'stmt> = Row<'a, 'stmt>;
|
||||
|
||||
/// A single result row of a query.
|
||||
@@ -1168,14 +1173,17 @@ impl<'a> ValueRef<'a> {
|
||||
}
|
||||
ffi::SQLITE_BLOB => {
|
||||
let blob = ffi::sqlite3_column_blob(raw, col);
|
||||
assert!(!blob.is_null(),
|
||||
"unexpected SQLITE_BLOB column type with NULL data");
|
||||
|
||||
let len = ffi::sqlite3_column_bytes(raw, col);
|
||||
assert!(len >= 0,
|
||||
"unexpected negative return from sqlite3_column_bytes");
|
||||
assert!(len >= 0, "unexpected negative return from sqlite3_column_bytes");
|
||||
if len > 0 {
|
||||
assert!(!blob.is_null(), "unexpected SQLITE_BLOB column type with NULL data");
|
||||
ValueRef::Blob(from_raw_parts(blob as *const u8, len as usize))
|
||||
} else {
|
||||
// The return value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
|
||||
ValueRef::Blob(&[])
|
||||
}
|
||||
|
||||
ValueRef::Blob(from_raw_parts(blob as *const u8, len as usize))
|
||||
}
|
||||
_ => unreachable!("sqlite3_column_type returned invalid value"),
|
||||
}
|
||||
|
Reference in New Issue
Block a user