MCPcopy Create free account
hub / github.com/erans/pgsqlite / test_result_cache_invalidation_on_ddl

Function test_result_cache_invalidation_on_ddl

tests/result_cache_test.rs:66–95  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

64
65#[tokio::test]
66async fn test_result_cache_invalidation_on_ddl() {
67 let test_server = setup_test_server_with_init(|db| {
68 Box::pin(async move {
69 // Create initial table
70 db.execute("CREATE TABLE ddl_test (id INTEGER PRIMARY KEY, data TEXT)").await?;
71 db.execute("INSERT INTO ddl_test VALUES (1, 'original')").await?;
72 Ok(())
73 })
74 }).await;
75
76 let client = &test_server.client;
77
78 // Execute a query that should be cached
79 let query = "SELECT * FROM ddl_test";
80 let rows1 = client.query(query, &[]).await.unwrap();
81 assert_eq!(rows1.len(), 1);
82 assert_eq!(rows1[0].get::<_, String>(1), "original");
83
84 // Execute DDL which should clear the cache
85 client.execute("ALTER TABLE ddl_test ADD COLUMN extra INTEGER DEFAULT 0", &[]).await.unwrap();
86
87 // Insert new data
88 client.execute("INSERT INTO ddl_test (id, data) VALUES (2, 'new')", &[]).await.unwrap();
89
90 // Execute the same query - should not use cached result
91 let rows2 = client.query(query, &[]).await.unwrap();
92 assert_eq!(rows2.len(), 2); // Should see both rows, not cached single row
93
94 test_server.abort();
95}
96
97#[tokio::test]
98async fn test_result_cache_not_used_for_dml() {

Callers

nothing calls this directly

Calls 4

abortMethod · 0.80
executeMethod · 0.45
queryMethod · 0.45

Tested by

no test coverage detected