Merge 'Simulator: fix alter table shadowing to modify index column name ' from Pedro Muniz

Forgot to modify the column name referenced in the indexes when
shadowing

Reviewed-by: bit-aloo (@Shourya742)

Closes #3712
This commit is contained in:
Jussi Saurio
2025-10-14 07:25:29 +03:00
committed by GitHub

View File

@@ -579,10 +579,24 @@ impl Shadow for AlterTable {
AlterTableType::AlterColumn { old, new } => {
let col = table.columns.iter_mut().find(|c| c.name == *old).unwrap();
*col = new.clone();
table.indexes.iter_mut().for_each(|index| {
index.columns.iter_mut().for_each(|(col_name, _)| {
if col_name == old {
*col_name = new.name.clone();
}
});
});
}
AlterTableType::RenameColumn { old, new } => {
let col = table.columns.iter_mut().find(|c| c.name == *old).unwrap();
col.name = new.clone();
table.indexes.iter_mut().for_each(|index| {
index.columns.iter_mut().for_each(|(col_name, _)| {
if col_name == old {
*col_name = new.clone();
}
});
});
}
AlterTableType::DropColumn { column_name } => {
let col_idx = table