mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-06 09:44:21 +01:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user