()
| 75 | |
| 76 | #[test] |
| 77 | fn update_row() { |
| 78 | let mut engine = MutationEngine::new("test".into(), test_schema()); |
| 79 | |
| 80 | engine |
| 81 | .insert(&[ |
| 82 | Value::Integer(1), |
| 83 | Value::String("Alice".into()), |
| 84 | Value::Float(0.5), |
| 85 | ]) |
| 86 | .expect("insert"); |
| 87 | |
| 88 | // Update: change name and score, keep same PK. |
| 89 | let result = engine |
| 90 | .update( |
| 91 | &Value::Integer(1), |
| 92 | &[ |
| 93 | Value::Integer(1), |
| 94 | Value::String("Alice Updated".into()), |
| 95 | Value::Float(0.75), |
| 96 | ], |
| 97 | ) |
| 98 | .expect("update"); |
| 99 | |
| 100 | // Should produce 2 WAL records: delete + insert. |
| 101 | assert_eq!(result.wal_records.len(), 2); |
| 102 | assert!(matches!( |
| 103 | &result.wal_records[0], |
| 104 | ColumnarWalRecord::DeleteRows { .. } |
| 105 | )); |
| 106 | assert!(matches!( |
| 107 | &result.wal_records[1], |
| 108 | ColumnarWalRecord::InsertRow { .. } |
| 109 | )); |
| 110 | |
| 111 | // PK index should still have 1 entry. |
| 112 | assert_eq!(engine.pk_index().len(), 1); |
| 113 | // Memtable should have 2 rows (original + updated). |
| 114 | assert_eq!(engine.memtable().row_count(), 2); |
| 115 | } |
| 116 | |
| 117 | #[test] |
| 118 | fn memtable_flush_remaps_pk() { |
nothing calls this directly
no test coverage detected