mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-23 00:39:20 +08:00
Update for int/uint -> isize/usize
This commit is contained in:
parent
60c9a04161
commit
cc8a68ca83
@ -42,7 +42,7 @@ pub const SQLITE_NULL : c_int = 5;
|
|||||||
pub type SqliteDestructor = extern "C" fn(*mut c_void);
|
pub type SqliteDestructor = extern "C" fn(*mut c_void);
|
||||||
|
|
||||||
pub fn SQLITE_TRANSIENT() -> SqliteDestructor {
|
pub fn SQLITE_TRANSIENT() -> SqliteDestructor {
|
||||||
unsafe { mem::transmute(-1i) }
|
unsafe { mem::transmute(-1is) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn code_to_str(code: c_int) -> &'static str {
|
pub fn code_to_str(code: c_int) -> &'static str {
|
||||||
|
12
src/lib.rs
12
src/lib.rs
@ -210,7 +210,7 @@ impl SqliteConnection {
|
|||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn execute(&self, sql: &str, params: &[&ToSql]) -> SqliteResult<uint> {
|
pub fn execute(&self, sql: &str, params: &[&ToSql]) -> SqliteResult<c_int> {
|
||||||
self.prepare(sql).and_then(|mut stmt| stmt.execute(params))
|
self.prepare(sql).and_then(|mut stmt| stmt.execute(params))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,7 +280,7 @@ impl SqliteConnection {
|
|||||||
self.db.borrow_mut().decode_result(code)
|
self.db.borrow_mut().decode_result(code)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn changes(&self) -> uint {
|
fn changes(&self) -> c_int {
|
||||||
self.db.borrow_mut().changes()
|
self.db.borrow_mut().changes()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -390,8 +390,8 @@ impl InnerSqliteConnection {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn changes(&mut self) -> uint {
|
fn changes(&mut self) -> c_int {
|
||||||
unsafe{ ffi::sqlite3_changes(self.db) as uint }
|
unsafe{ ffi::sqlite3_changes(self.db) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,7 +432,7 @@ impl<'conn> SqliteStatement<'conn> {
|
|||||||
/// Ok(())
|
/// Ok(())
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn execute(&mut self, params: &[&ToSql]) -> SqliteResult<uint> {
|
pub fn execute(&mut self, params: &[&ToSql]) -> SqliteResult<c_int> {
|
||||||
self.reset_if_needed();
|
self.reset_if_needed();
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
@ -796,7 +796,7 @@ mod test {
|
|||||||
assert_eq!(db.last_insert_rowid(), 1);
|
assert_eq!(db.last_insert_rowid(), 1);
|
||||||
|
|
||||||
let mut stmt = db.prepare("INSERT INTO foo DEFAULT VALUES").unwrap();
|
let mut stmt = db.prepare("INSERT INTO foo DEFAULT VALUES").unwrap();
|
||||||
for _ in range(0i, 9) {
|
for _ in range(0i32, 9) {
|
||||||
stmt.execute(&[]).unwrap();
|
stmt.execute(&[]).unwrap();
|
||||||
}
|
}
|
||||||
assert_eq!(db.last_insert_rowid(), 10);
|
assert_eq!(db.last_insert_rowid(), 10);
|
||||||
|
10
src/types.rs
10
src/types.rs
@ -136,9 +136,15 @@ impl<T: ToSql> ToSql for Option<T> {
|
|||||||
/// ## Example
|
/// ## Example
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
|
/// #![allow(unstable)]
|
||||||
|
/// # extern crate libc;
|
||||||
|
/// # extern crate rusqlite;
|
||||||
/// # use rusqlite::{SqliteConnection, SqliteResult};
|
/// # use rusqlite::{SqliteConnection, SqliteResult};
|
||||||
/// # use rusqlite::types::{Null};
|
/// # use rusqlite::types::{Null};
|
||||||
/// fn insert_null(conn: &SqliteConnection) -> SqliteResult<uint> {
|
/// # use libc::{c_int};
|
||||||
|
/// fn main() {
|
||||||
|
/// }
|
||||||
|
/// fn insert_null(conn: &SqliteConnection) -> SqliteResult<c_int> {
|
||||||
/// conn.execute("INSERT INTO people (name) VALUES (?)", &[&Null])
|
/// conn.execute("INSERT INTO people (name) VALUES (?)", &[&Null])
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
@ -186,7 +192,7 @@ impl FromSql for Vec<u8> {
|
|||||||
let c_blob = ffi::sqlite3_column_blob(stmt, col);
|
let c_blob = ffi::sqlite3_column_blob(stmt, col);
|
||||||
let len = ffi::sqlite3_column_bytes(stmt, col);
|
let len = ffi::sqlite3_column_bytes(stmt, col);
|
||||||
|
|
||||||
assert!(len >= 0); let len = len as uint;
|
assert!(len >= 0); let len = len as usize;
|
||||||
|
|
||||||
Ok(Vec::from_raw_buf(mem::transmute(c_blob), len))
|
Ok(Vec::from_raw_buf(mem::transmute(c_blob), len))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user