Bug #43061 Views Not Exported Correctly
Submitted: 20 Feb 2009 15:55 Modified: 10 Aug 2009 12:54
Reporter: David Weingart Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench Severity:S3 (Non-critical)
Version:5.0.30 OSS OS:Windows
Assigned to: Alexander Musienko CPU Architecture:Any
Tags: CHECKED

[20 Feb 2009 15:55] David Weingart
Description:
The create script created by running "Forward Engineer SQL Create Script" fails with an error if any view references a column defined in another view.

This is because the temporary table structure generated by Workbench for views (to resolve dependency order problems) is incomplete. It only creates an "id" column for each view, instead of parsing the view definition and creating the actual columns contained in the view.

This prevents some views from being created because the reference non-existent columns.

How to repeat:
Create two views, one of which references a column in the other. It's important that they be defined in the wrong alphabetical order.

CREATE VIEW `view1` AS
SELECT c FROM view2

CREATE VIEW `view2` AS
SELECT 'Hello World' AS c

Then run Export -> Forward Engineer SQL Create Script

The script will fail with the error:  Unknown column 'c' in 'field list'

Suggested fix:
Parse the view definitions to create the proper temporary table structure (similar to how mysqldump operates)
[20 Feb 2009 16:31] MySQL Verification Team
Thank you for the bug report.
[6 Aug 2009 20:21] Johannes Taxacher
the dummy objects created for the views first-hand now contain the correct column-names (all defined as simple INT columns) so that referring views can be created.
fix will be in 5.1.17
[6 Aug 2009 20:28] Johannes Taxacher
the dummy objects created for the views first-hand now contain the correct column-names (all defined as simple INT columns) so that referring views can be created.
fix will be in 5.1.17
[6 Aug 2009 20:36] Johannes Taxacher
the dummy objects created for the views first-hand now contain the correct column-names (all defined as simple INT columns) so that referring views can be created.
fix will be in 5.1.17
[10 Aug 2009 12:54] Tony Bedford
An entry was added to the 5.1.17 changelog:

The script created by Forward Engineer SQL CREATE Script failed with an error if the model contained a view that referenced a column defined in another view.