Bug #53136 | Textual queries generated by "Copy SQL to Clipboard" don't work on Connected DB | ||
---|---|---|---|
Submitted: | 23 Apr 2010 23:39 | Modified: | 11 May 2010 10:02 |
Reporter: | Joshua Levin | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Workbench: Modeling | Severity: | S2 (Serious) |
Version: | 5.2.19 OSS Beta Rev. 5680 | OS: | Windows (Vista) |
Assigned to: | Alfredo Kojima | CPU Architecture: | Any |
[23 Apr 2010 23:39]
Joshua Levin
[24 Apr 2010 15:57]
Valeriy Kravchuk
Can you, please, send CREATE TABLE statement for that PUBLICATIONS table (via the same Copy SQL to Clipboard menu item, for example). I need to know how `IssuesPerYear` column is defined.
[24 Apr 2010 17:18]
Joshua Levin
The SQL queries to generate the PUBLICATIONS table is as follows (some comments have been removed for security reasons): CREATE TABLE IF NOT EXISTS `mydb`.`PUBLICATIONS` ( `PubID` INT NOT NULL , `PubName` VARCHAR(80) NULL , `PubAbbrev` VARCHAR(8) NULL , `PubAbbrevAlt` VARCHAR(8) NULL , `IssuesPerYear` SMALLINT(6) NULL , PRIMARY KEY (`PubID`) , INDEX `PubID` (`PubID` ASC) ) ENGINE = InnoDB COMMENT = 'List of Publications'
[24 Apr 2010 18:29]
Valeriy Kravchuk
Indeed, MySQL Workbench allows to declare incorrect foreign key that references to column without PRIMARY KEY or even UNIQUE key declaration, like this: CREATE TABLE IF NOT EXISTS `mydb`.`table1` ( `id1` INT NOT NULL , `id2` VARCHAR(45) NULL , PRIMARY KEY (`id1`) ) ENGINE = InnoDB; CREATE TABLE IF NOT EXISTS `mydb`.`table2` ( `id1` INT NOT NULL , `id2` VARCHAR(45) NULL , PRIMARY KEY (`id1`) , INDEX `fk1` (`id2` ASC) , CONSTRAINT `fk1` FOREIGN KEY (`id2` ) REFERENCES `mydb`.`table1` (`id2` ) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; Maybe some validation module in SE edition will catch this, but for now this is a bug. IMHO interface should prevent creation of incorrect foreign keys.
[1 May 2010 1:26]
Alfredo Kojima
In FK editor, added filtering to list of columns allowed for a referenced FK so that only PK and indexed columns are allowed.
[1 May 2010 18:52]
Joshua Levin
This seems to have been completely corrected in 5.2.20 OSS Beta Rev. 5783
[10 May 2010 22:25]
Johannes Taxacher
fix confirmed in repository
[10 May 2010 22:26]
Johannes Taxacher
fix confirmed in repository
[11 May 2010 10:02]
Tony Bedford
An entry has been added to the 5.2.21 changelog: MySQL Workbench allowed the creation of invalid foreign keys that referenced a column that did not use a PRIMARY KEY or UNIQUE key declaration. MySQL Workbench has been changed to filter the list of columns allowed for a referenced foreign key, so that only primary key and indexed columns are listed.