Bug #51939 Foreign key from a renamed table throws error
Submitted: 11 Mar 2010 2:01 Modified: 14 May 2010 17:48
Reporter: Charles Whipple Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Workbench: Modeling Severity:S2 (Serious)
Version:5.2.16 , 5.2.19 OSS Beta OS:Windows (Windows 7)
Assigned to: CPU Architecture:Any
Tags: Object Explorer Bug

[11 Mar 2010 2:01] Charles Whipple
Description:
Error in the TreeView control while designing table from the object explorer.  

How to repeat:
1. Create two tables.  One with a primary key and one with a foreign key referencing it.  
2. Rename the parent table.  
3. From the context menu, available in the object explorer, click [alter table...]
4. Move to the tab [Foreign Keys] and click on the foreign key of the parent table.  
5. Watch the fireworks.  

Suggested fix:
Either stop the renaming of the parent table if a foreign key points to it or check to see if a foreign key exists, if it does rename the table that it is pointing to.
[23 Apr 2010 15:45] Valeriy Kravchuk
Please, check with a newer version, 5.2.19, and inform about the results.
[24 Apr 2010 2:51] Charles Whipple
My apologies, the last message should go on the bug [#52589 [Com,Opn->Fbk]: Autolayout Unhandled Exception].  I'll reply to it and please omit the last response.
[24 Apr 2010 3:08] Charles Whipple
Okay, I created a child table.  

CREATE TABLE `child` (
  `ChildID` int(11) NOT NULL AUTO_INCREMENT,
  `child_stuff` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`idchild`),
  KEY `parent_id` (`idchild`),
  CONSTRAINT `parent_id` FOREIGN KEY (`idchild`) REFERENCES `parent` (`ParentID`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1

Then created a Parent table: 
CREATE TABLE `parent` (
  `ParentID` int(11) NOT NULL AUTO_INCREMENT,
  `stuff` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`ParentID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1

When I rename a table (by right-clicking -> Alter Table...), it does not detect any changes.  So I renamed the table and added a column, and it continues to say, "No changes to object were detected."  If this is the solution, it is far from adequate.  It should at least inform the user that there is a foreign key referencing this table and it cannot be renamed.  I don't think this is a practical solution either.  It should correct the reference.  It almost appears to be linked to the name, which is a terrible way of doing this.  It should be linked, internally, by an object ID.
[26 Apr 2010 7:49] Sveta Smirnova
Thank you for the feedback.

Have you tried version 5.2.19? In my environment all changes displayed in edit area for child table.
[26 Apr 2010 13:16] Charles Whipple
Yes, (5.2.19) is the version I am currently running.  I was told to update in response to another bug I was trying to help resolve.
[12 May 2010 16:09] Valeriy Kravchuk
Please, check with a newer version, 5.2.21, and inform about the results.
[14 May 2010 4:00] Charles Whipple
Seems to be working!  Thanks guys.
[14 May 2010 17:48] Valeriy Kravchuk
Not repeatable with 5.2.21.