mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-22 16:29:20 +08:00
Replace row changes/count type (i32) with usize
Breaking change
This commit is contained in:
parent
c6f4ae632a
commit
0d0a7bf81f
@ -62,7 +62,7 @@ pub enum Error {
|
||||
InvalidColumnType(usize, Type),
|
||||
|
||||
/// Error when a query that was expected to insert one row did not insert any or insert many.
|
||||
StatementChangedRows(c_int),
|
||||
StatementChangedRows(usize),
|
||||
|
||||
/// Error returned by `functions::Context::get` when the function argument cannot be converted
|
||||
/// to the requested type.
|
||||
|
12
src/lib.rs
12
src/lib.rs
@ -305,7 +305,7 @@ impl Connection {
|
||||
///
|
||||
/// Will return `Err` if `sql` cannot be converted to a C-compatible string or if the
|
||||
/// underlying SQLite call fails.
|
||||
pub fn execute(&self, sql: &str, params: &[&ToSql]) -> Result<c_int> {
|
||||
pub fn execute(&self, sql: &str, params: &[&ToSql]) -> Result<usize> {
|
||||
self.prepare(sql)
|
||||
.and_then(|mut stmt| stmt.execute(params))
|
||||
}
|
||||
@ -319,7 +319,7 @@ impl Connection {
|
||||
///
|
||||
/// ```rust,no_run
|
||||
/// # use rusqlite::{Connection, Result};
|
||||
/// fn insert(conn: &Connection) -> Result<i32> {
|
||||
/// fn insert(conn: &Connection) -> Result<usize> {
|
||||
/// conn.execute_named("INSERT INTO test (name) VALUES (:name)", &[(":name", &"one")])
|
||||
/// }
|
||||
/// ```
|
||||
@ -328,7 +328,7 @@ impl Connection {
|
||||
///
|
||||
/// Will return `Err` if `sql` cannot be converted to a C-compatible string or if the
|
||||
/// underlying SQLite call fails.
|
||||
pub fn execute_named(&self, sql: &str, params: &[(&str, &ToSql)]) -> Result<c_int> {
|
||||
pub fn execute_named(&self, sql: &str, params: &[(&str, &ToSql)]) -> Result<usize> {
|
||||
self.prepare(sql)
|
||||
.and_then(|mut stmt| stmt.execute_named(params))
|
||||
}
|
||||
@ -570,7 +570,7 @@ impl Connection {
|
||||
self.db.borrow_mut().decode_result(code)
|
||||
}
|
||||
|
||||
fn changes(&self) -> c_int {
|
||||
fn changes(&self) -> usize {
|
||||
self.db.borrow_mut().changes()
|
||||
}
|
||||
|
||||
@ -911,8 +911,8 @@ impl InnerConnection {
|
||||
})
|
||||
}
|
||||
|
||||
fn changes(&mut self) -> c_int {
|
||||
unsafe { ffi::sqlite3_changes(self.db()) }
|
||||
fn changes(&mut self) -> usize {
|
||||
unsafe { ffi::sqlite3_changes(self.db()) as usize }
|
||||
}
|
||||
|
||||
fn is_autocommit(&self) -> bool {
|
||||
|
@ -75,7 +75,7 @@ impl<'conn> Statement<'conn> {
|
||||
///
|
||||
/// Will return `Err` if binding parameters fails, the executed statement returns rows (in
|
||||
/// which case `query` should be used instead), or the underling SQLite call fails.
|
||||
pub fn execute(&mut self, params: &[&ToSql]) -> Result<c_int> {
|
||||
pub fn execute(&mut self, params: &[&ToSql]) -> Result<usize> {
|
||||
try!(self.bind_parameters(params));
|
||||
self.execute_with_bound_parameters()
|
||||
}
|
||||
@ -92,7 +92,7 @@ impl<'conn> Statement<'conn> {
|
||||
///
|
||||
/// ```rust,no_run
|
||||
/// # use rusqlite::{Connection, Result};
|
||||
/// fn insert(conn: &Connection) -> Result<i32> {
|
||||
/// fn insert(conn: &Connection) -> Result<usize> {
|
||||
/// let mut stmt = try!(conn.prepare("INSERT INTO test (name) VALUES (:name)"));
|
||||
/// stmt.execute_named(&[(":name", &"one")])
|
||||
/// }
|
||||
@ -102,7 +102,7 @@ impl<'conn> Statement<'conn> {
|
||||
///
|
||||
/// Will return `Err` if binding parameters fails, the executed statement returns rows (in
|
||||
/// which case `query` should be used instead), or the underling SQLite call fails.
|
||||
pub fn execute_named(&mut self, params: &[(&str, &ToSql)]) -> Result<c_int> {
|
||||
pub fn execute_named(&mut self, params: &[(&str, &ToSql)]) -> Result<usize> {
|
||||
try!(self.bind_parameters_named(params));
|
||||
self.execute_with_bound_parameters()
|
||||
}
|
||||
@ -445,7 +445,7 @@ impl<'conn> Statement<'conn> {
|
||||
})
|
||||
}
|
||||
|
||||
fn execute_with_bound_parameters(&mut self) -> Result<c_int> {
|
||||
fn execute_with_bound_parameters(&mut self) -> Result<usize> {
|
||||
let r = self.stmt.step();
|
||||
self.stmt.reset();
|
||||
match r {
|
||||
|
@ -77,10 +77,9 @@ mod serde_json;
|
||||
/// # extern crate rusqlite;
|
||||
/// # use rusqlite::{Connection, Result};
|
||||
/// # use rusqlite::types::{Null};
|
||||
/// # use std::os::raw::{c_int};
|
||||
/// fn main() {
|
||||
/// }
|
||||
/// fn insert_null(conn: &Connection) -> Result<c_int> {
|
||||
/// fn insert_null(conn: &Connection) -> Result<usize> {
|
||||
/// conn.execute("INSERT INTO people (name) VALUES (?)", &[&Null])
|
||||
/// }
|
||||
/// ```
|
||||
|
Loading…
Reference in New Issue
Block a user