Bug #31979 Quote default values when needed or make validation tell the user to do so
Submitted: 31 Oct 2007 9:21 Modified: 25 Jun 2010 8:30
Reporter: Ulf Wendel Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench Severity:S4 (Feature request)
Version:1.0.6 Alpha OS:Windows
Assigned to: CPU Architecture:Any

[31 Oct 2007 9:21] Ulf Wendel
Description:
Make sure you quote default values of columns when needed, otherwise you export invalid SQL. If you do not want to do the quoting, make validation warn the user if a default looks error prone (because it lacks quotes).

Please note this is about WB 1.0.6 Alpha. 1.0.6 Alpha is newer than 1.1.10. You can download it from https://inside.mysql.com/wiki/MySQLWorkbenchAlphaReleases . Please note also the special and temporary handling of pre-beta bug reports. 

How to repeat:
Start WB, create a table "table1":

id INT PRIMARY KEY
col1 SET('one', 'two', 'three') DEFAULT one 

Make sure you do not enter any quotes in the Default input field of the table editors column tab. Create a diagram, drag the table from the Catalog on it, open the Output window, validate the model. Validation will not bail.

Export a SQL CREATE script:

CREATE  TABLE IF NOT EXISTS `mydb`.`table1` (`id` INT  NOT NULL , `col1` SET('one', 'two', 'three')  NULL DEFAULT one , PRIMARY KEY (`id`) ) ;

And run the SQL from WB:

CREATE  TABLE IF NOT EXISTS `mydb`.`table1` (`id` INT  NOT NULL , `col1` SET('one', 'two', 'three')  NULL DEFAULT one , PRIMARY KEY (`id`) ) ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'one , PRIMARY KEY (`id`) )' at line 1

Same game can of course be played also with ENUM() and likely other column types as well (haven't checked any other but ENUM).
[6 Nov 2007 17:39] Andrii Nikitin
It is planned to add syntax check to column definition later
[25 Jun 2010 8:30] Mike Lischke
Fix already released.