From 45567e6837613c50b73175e20b7e2c815fcdcba6 Mon Sep 17 00:00:00 2001 From: pedrocarlo Date: Mon, 13 Oct 2025 13:59:25 -0300 Subject: [PATCH] fix alter table shadowing to modify index column name on rename and alter --- simulator/model/mod.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/simulator/model/mod.rs b/simulator/model/mod.rs index 20726cbbb..40fbde612 100644 --- a/simulator/model/mod.rs +++ b/simulator/model/mod.rs @@ -563,10 +563,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