test_total_changes

This commit is contained in:
François 2024-02-27 14:53:50 +01:00
parent 673a69d3c6
commit 87e5e192e5

View File

@ -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()?;