Bug #51516 Can't alter a recently added column
Submitted: 25 Feb 2010 16:41 Modified: 16 Apr 2010 14:47
Reporter: Greg Thomas Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench: SQL Editor Severity:S3 (Non-critical)
Version:5.2.16 Revision 5249 OS:Any
Assigned to: Sergei Tkachenko CPU Architecture:Any

[25 Feb 2010 16:41] Greg Thomas
Description:
If you're altering a table, then once you've added a new column, it's not possible to alter it - the generated SQL attempts to add it a second time. 

How to repeat:
1. Select "Alter table..." on an existing table. 
2. Add a new column "test_column", of type VARCHAR(45)
3. Click "Apply"
4. Generated SQL is shown ...
ALTER TABLE `test`.`test` ADD COLUMN `test_column` VARCHAR(45) NULL  AFTER `foo` ;
5. Click "Apply SQL"
6. Confirmation that the column was added is shown. Click "Finish" to return to the table designer. 
7. Alter the type of the column from VARCHAR(45) to VARCHAR(145). Click "Apply"
8. Generated SQL is shown ...
ALTER TABLE `test`.`test` ADD COLUMN `test_column` VARCHAR(145) NULL  AFTER `foo` ;
5. Click "Apply SQL"
6. An error is displayed:
ERROR 1060: Duplicate column name 'test_column'

SQL Statement:

ALTER TABLE `test`.`test` ADD COLUMN `test_column` VARCHAR(145) NULL  AFTER `foo`

Suggested fix:
After the "Finish" button is clicked, the table designer should refresh the design of the table, so that it is aware the column should be altered not added.
[25 Feb 2010 17:07] Valeriy Kravchuk
Thank you for the bug report. Verified just as described on Mac OS X.
[30 Mar 2010 20:17] Johannes Taxacher
fixed in repository
[30 Mar 2010 20:20] Johannes Taxacher
Bug #51719 has been marked as duplicate of this one
[16 Apr 2010 14:47] Tony Bedford
An entry has been added to the 5.2.17 changelog:

In the Alter Table dialog of the SQL Editor, if a column was added to a table, and then an attempt made to alter that column's datatype, then the wizard generated ADD COLUMN code, rather than CHANGE COLUMN. This resulted in the following error when an attempt was made to apply the changes:

ERROR 1060: Duplicate column name 'test_column'