mirror of
https://github.com/isar/rusqlite.git
synced 2025-03-29 00:32:57 +08:00
test_total_changes
This commit is contained in:
parent
673a69d3c6
commit
87e5e192e5
21
src/lib.rs
21
src/lib.rs
@ -1703,6 +1703,27 @@ mod test {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_total_changes() -> Result<()> {
|
||||
let db = Connection::open_in_memory()?;
|
||||
let sql = "CREATE TABLE foo(x INTEGER PRIMARY KEY, value TEXT defaut '' NOT NULL,
|
||||
desc TEXT default '');
|
||||
CREATE VIEW foo_bar AS SELECT x, desc FROM foo WHERE value = 'bar';
|
||||
CREATE TRIGGER INSERT_FOOBAR
|
||||
INSTEAD OF INSERT
|
||||
ON foo_bar
|
||||
BEGIN
|
||||
INSERT INTO foo VALUES(new.x, 'bar', new.desc);
|
||||
END;";
|
||||
db.execute_batch(sql)?;
|
||||
let total_changes_before = db.total_changes();
|
||||
let changes = db.prepare("INSERT INTO foo_bar VALUES(null, 'baz');")?.execute([])?;
|
||||
let total_changes_after = db.total_changes();
|
||||
assert_eq!(changes, 0);
|
||||
assert_eq!(total_changes_after - total_changes_before, 1);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_is_autocommit() -> Result<()> {
|
||||
let db = Connection::open_in_memory()?;
|
||||
|
Loading…
x
Reference in New Issue
Block a user