This commit is contained in:
gwenn 2016-05-20 18:36:44 +02:00
parent 0740620ffe
commit cbc479c484
4 changed files with 19 additions and 11 deletions

View File

@ -109,7 +109,9 @@ impl fmt::Display for Error {
Error::QueryReturnedNoRows => write!(f, "Query returned no rows"),
Error::InvalidColumnIndex(i) => write!(f, "Invalid column index: {}", i),
Error::InvalidColumnName(ref name) => write!(f, "Invalid column name: {}", name),
Error::InvalidColumnType(i, t) => write!(f, "Invalid column type {} at index: {}", t, i),
Error::InvalidColumnType(i, t) => {
write!(f, "Invalid column type {} at index: {}", t, i)
}
Error::StatementChangedRows(i) => write!(f, "Query changed {} rows", i),
Error::StatementFailedToInsertRow => write!(f, "Statement failed to insert new row"),

View File

@ -88,7 +88,10 @@ pub trait FromSql: Sized {
}
}
unsafe fn column_has_expected_typed(stmt: *mut sqlite3_stmt, col: c_int, expected_type: c_int) -> Result<()> {
unsafe fn column_has_expected_typed(stmt: *mut sqlite3_stmt,
col: c_int,
expected_type: c_int)
-> Result<()> {
let actual_type = sqlite3_column_type(stmt, col);
if actual_type == expected_type {
Ok(())

View File

@ -244,7 +244,8 @@ mod test {
assert_eq!(vec!["rowid", "colA", "colB", "colC"], headers);
}
let ids: Result<Vec<i32>> = s.query_map(&[], |row| row.get::<i32, i32>(0)).unwrap().collect();
let ids: Result<Vec<i32>> =
s.query_map(&[], |row| row.get::<i32, i32>(0)).unwrap().collect();
let sum = ids.unwrap().iter().fold(0, |acc, &id| acc + id);
assert_eq!(sum, 15);
}
@ -258,8 +259,9 @@ mod test {
db.execute_batch("CREATE VIRTUAL TABLE vtab USING csv('test.csv', HAS_HEADERS)").unwrap();
{
let mut s = db.prepare("SELECT v1.rowid, v1.* FROM vtab v1 NATURAL JOIN vtab v2 \
WHERE v1.rowid < v2.rowid")
let mut s =
db.prepare("SELECT v1.rowid, v1.* FROM vtab v1 NATURAL JOIN vtab v2 WHERE \
v1.rowid < v2.rowid")
.unwrap();
let mut rows = s.query(&[]).unwrap();

View File

@ -31,8 +31,9 @@ pub fn drop_int_array(conn: &Connection, name: &str) -> Result<()> {
conn.execute_batch(&format!("DROP TABLE temp.\"{0}\"", escape_double_quote(name)))
// http://www.mail-archive.com/sqlite-users%40mailinglists.sqlite.org/msg08423.html
// "Once a virtual table module has been created, it cannot be modified or destroyed, except by closing the database connection."
/*let aux: Option<()> = None;
conn.create_module(name, ptr::null() as *const ffi::sqlite3_module, aux)*/
// let aux: Option<()> = None;
// conn.create_module(name, ptr::null() as *const ffi::sqlite3_module, aux)
}
init_module!(INT_ARRAY_MODULE,