mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-26 19:41:37 +08:00
Test Batch iterator
This commit is contained in:
parent
f3c2b63836
commit
1103febb1e
24
src/lib.rs
24
src/lib.rs
@ -1810,6 +1810,7 @@ mod test {
|
|||||||
err => panic!("Unexpected error {}", err),
|
err => panic!("Unexpected error {}", err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_dynamic() {
|
fn test_dynamic() {
|
||||||
@ -1820,7 +1821,7 @@ mod test {
|
|||||||
END;";
|
END;";
|
||||||
db.execute_batch(sql).unwrap();
|
db.execute_batch(sql).unwrap();
|
||||||
|
|
||||||
db.query_row("SELECT * FROM foo", params![], |r| {
|
db.query_row("SELECT * FROM foo", NO_PARAMS, |r| {
|
||||||
assert_eq!(2, r.column_count());
|
assert_eq!(2, r.column_count());
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
@ -1832,7 +1833,7 @@ mod test {
|
|||||||
db.execute_batch("CREATE TABLE foo(x INTEGER);").unwrap();
|
db.execute_batch("CREATE TABLE foo(x INTEGER);").unwrap();
|
||||||
let b: Box<dyn ToSql> = Box::new(5);
|
let b: Box<dyn ToSql> = Box::new(5);
|
||||||
db.execute("INSERT INTO foo VALUES(?)", &[b]).unwrap();
|
db.execute("INSERT INTO foo VALUES(?)", &[b]).unwrap();
|
||||||
db.query_row("SELECT x FROM foo", params![], |r| {
|
db.query_row("SELECT x FROM foo", NO_PARAMS, |r| {
|
||||||
assert_eq!(5, r.get_unwrap::<_, i32>(0));
|
assert_eq!(5, r.get_unwrap::<_, i32>(0));
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
@ -1849,8 +1850,8 @@ mod test {
|
|||||||
?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
||||||
?, ?, ?, ?;",
|
?, ?, ?, ?;",
|
||||||
params![
|
params![
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
1, 1, 1, 1, 1, 1, 1, 1,
|
1, 1, 1, 1, 1, 1,
|
||||||
],
|
],
|
||||||
|r| {
|
|r| {
|
||||||
assert_eq!(1, r.get_unwrap::<_, i32>(0));
|
assert_eq!(1, r.get_unwrap::<_, i32>(0));
|
||||||
@ -1866,7 +1867,20 @@ mod test {
|
|||||||
let db = checked_memory_handle();
|
let db = checked_memory_handle();
|
||||||
db.execute_batch("CREATE TABLE x(t);").unwrap();
|
db.execute_batch("CREATE TABLE x(t);").unwrap();
|
||||||
// `execute_batch` should be used but `execute` should also work
|
// `execute_batch` should be used but `execute` should also work
|
||||||
db.execute("ALTER TABLE x RENAME TO y;", params![]).unwrap();
|
db.execute("ALTER TABLE x RENAME TO y;", NO_PARAMS).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_batch() {
|
||||||
|
let db = checked_memory_handle();
|
||||||
|
let sql = r"
|
||||||
|
CREATE TABLE tbl1 (col);
|
||||||
|
CREATE TABLE tbl2 (col);
|
||||||
|
";
|
||||||
|
let batch = Batch::new(&db, sql);
|
||||||
|
for stmt in batch {
|
||||||
|
let mut stmt = stmt.unwrap();
|
||||||
|
stmt.execute(NO_PARAMS).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user