mirror of
				https://github.com/isar/rusqlite.git
				synced 2025-10-31 13:58:55 +08:00 
			
		
		
		
	test_total_changes
This commit is contained in:
		
							
								
								
									
										21
									
								
								src/lib.rs
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								src/lib.rs
									
									
									
									
									
								
							| @@ -1703,6 +1703,27 @@ mod test { | |||||||
|         Ok(()) |         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] |     #[test] | ||||||
|     fn test_is_autocommit() -> Result<()> { |     fn test_is_autocommit() -> Result<()> { | ||||||
|         let db = Connection::open_in_memory()?; |         let db = Connection::open_in_memory()?; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user