Update a row by PK: DELETE old + INSERT new. `updates` maps column names to new values. Columns not in the map retain their existing values from the old row. Returns WAL records for both the delete and the insert. NOTE: The caller must provide the full old row values for the re-insert. This method takes the complete new row (already merged with old values).
(
&mut self,
old_pk: &Value,
new_values: &[Value],
)
| 204 | /// NOTE: The caller must provide the full old row values for the re-insert. |
| 205 | /// This method takes the complete new row (already merged with old values). |
| 206 | pub fn update( |
| 207 | &mut self, |
| 208 | old_pk: &Value, |
| 209 | new_values: &[Value], |
| 210 | ) -> Result<MutationResult, ColumnarError> { |
| 211 | // Delete the old row. |
| 212 | let delete_result = self.delete(old_pk)?; |
| 213 | |
| 214 | // Insert the new row. |
| 215 | let insert_result = self.insert(new_values)?; |
| 216 | |
| 217 | // Combine WAL records. |
| 218 | let mut wal_records = delete_result.wal_records; |
| 219 | wal_records.extend(insert_result.wal_records); |
| 220 | |
| 221 | Ok(MutationResult { wal_records }) |
| 222 | } |
| 223 | } |