mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-23 00:39: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),
|
InvalidColumnType(usize, Type),
|
||||||
|
|
||||||
/// Error when a query that was expected to insert one row did not insert any or insert many.
|
/// 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
|
/// Error returned by `functions::Context::get` when the function argument cannot be converted
|
||||||
/// to the requested type.
|
/// 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
|
/// Will return `Err` if `sql` cannot be converted to a C-compatible string or if the
|
||||||
/// underlying SQLite call fails.
|
/// 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)
|
self.prepare(sql)
|
||||||
.and_then(|mut stmt| stmt.execute(params))
|
.and_then(|mut stmt| stmt.execute(params))
|
||||||
}
|
}
|
||||||
@ -319,7 +319,7 @@ impl Connection {
|
|||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # use rusqlite::{Connection, Result};
|
/// # 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")])
|
/// 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
|
/// Will return `Err` if `sql` cannot be converted to a C-compatible string or if the
|
||||||
/// underlying SQLite call fails.
|
/// 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)
|
self.prepare(sql)
|
||||||
.and_then(|mut stmt| stmt.execute_named(params))
|
.and_then(|mut stmt| stmt.execute_named(params))
|
||||||
}
|
}
|
||||||
@ -570,7 +570,7 @@ impl Connection {
|
|||||||
self.db.borrow_mut().decode_result(code)
|
self.db.borrow_mut().decode_result(code)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn changes(&self) -> c_int {
|
fn changes(&self) -> usize {
|
||||||
self.db.borrow_mut().changes()
|
self.db.borrow_mut().changes()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -911,8 +911,8 @@ impl InnerConnection {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn changes(&mut self) -> c_int {
|
fn changes(&mut self) -> usize {
|
||||||
unsafe { ffi::sqlite3_changes(self.db()) }
|
unsafe { ffi::sqlite3_changes(self.db()) as usize }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_autocommit(&self) -> bool {
|
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
|
/// 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.
|
/// 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));
|
try!(self.bind_parameters(params));
|
||||||
self.execute_with_bound_parameters()
|
self.execute_with_bound_parameters()
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@ impl<'conn> Statement<'conn> {
|
|||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # use rusqlite::{Connection, Result};
|
/// # 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)"));
|
/// let mut stmt = try!(conn.prepare("INSERT INTO test (name) VALUES (:name)"));
|
||||||
/// stmt.execute_named(&[(":name", &"one")])
|
/// 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
|
/// 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.
|
/// 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));
|
try!(self.bind_parameters_named(params));
|
||||||
self.execute_with_bound_parameters()
|
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();
|
let r = self.stmt.step();
|
||||||
self.stmt.reset();
|
self.stmt.reset();
|
||||||
match r {
|
match r {
|
||||||
|
@ -77,10 +77,9 @@ mod serde_json;
|
|||||||
/// # extern crate rusqlite;
|
/// # extern crate rusqlite;
|
||||||
/// # use rusqlite::{Connection, Result};
|
/// # use rusqlite::{Connection, Result};
|
||||||
/// # use rusqlite::types::{Null};
|
/// # use rusqlite::types::{Null};
|
||||||
/// # use std::os::raw::{c_int};
|
|
||||||
/// fn main() {
|
/// 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])
|
/// conn.execute("INSERT INTO people (name) VALUES (?)", &[&Null])
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
Loading…
Reference in New Issue
Block a user