Bug #38223 Export script creates invalid create schema and use statements
Submitted: 18 Jul 2008 14:02 Modified: 6 Feb 2013 13:52
Reporter: James Gordon Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench Severity:S3 (Non-critical)
Version:5.0.23 OS:Windows (XP)
Assigned to: CPU Architecture:Any

[18 Jul 2008 14:02] James Gordon
Description:
In the catalog rename the top-level node of the tree (database icon) to an empty string.

Forward Engineer to SQL Create script.

The script includes the following two invalid statements...

CREATE SCHEMA IF NOT EXISTS `` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
USE ``;

It also prefixes "create table", referneces statements.

There is also no way of switching of prefixing create statements with the schema name.

How to repeat:
In the catalog rename the top-level node of the tree (database icon) to an empty string.

Forward Engineer to SQL Create script.
[18 Jul 2008 14:03] James Gordon
WB file with empty database name

Attachment: BPSchema.mwb (application/x-zip-compressed, text), 21.96 KiB.

[18 Jul 2008 14:03] James Gordon
Created SQL file from attached WB file.

Attachment: bpschema.sql (text/plain), 17.92 KiB.

[18 Jul 2008 15:13] MySQL Verification Team
Thank you for the bug report.
[4 Aug 2008 11:06] Mike Lischke
Consider a useful enhancement (so it's kinda feature request): don't forward-engineer an empty schema name. This would also allow the script to be used on any schema.
[17 Mar 2009 14:02] Susanne Ebrecht
Change category to Workbench SE because validation checks are a feature of SE.
[18 Mar 2009 12:08] James Gordon
But the free version still needs to not write out invalid SQL by placing an empty schema name in front of it.
[25 Feb 2010 20:29] Ɓukasz Dejneka
The bug is still present in MySQL Workbench 5.2.15 OSS, Revision 5053, almost 2 years after initial submission. 

I know that its non-critical, but fixing it should be fairly easy (just don't add the line by default and leave the option in the SE version) and its a real pita when you need to delete the line every each time you synch.

Thanks !
[6 Feb 2013 13:52] Alfredo Kojima
Closing old bug.
Intentionally creating an invalid model will naturally create an invalid script. However, the result being attempted can already be obtained by using the "Omit Schema Qualifiers" export eoption.