Bug #31979 Quote default values when needed or make validation tell the user to do so
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).
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.039 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.