Bug #54377 Error exporting table comments in forward engineer SQL CREATE script
Submitted: 9 Jun 2010 18:00 Modified: 16 Jul 2010 23:18
Reporter: Daniel Davis Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Workbench Severity:S3 (Non-critical)
Version:5.2.22 OS:Any
Assigned to: CPU Architecture:Any
Tags: create, error, forward engineer, script

[9 Jun 2010 18:00] Daniel Davis
Description:
Tables with comments created in Workbench are not exported correctly when exporting the forward engineer create script.  The sql statements generated from the comments, must not be in the correct syntax.

How to repeat:
Create a new database model in mySQL Workbench.  Add comments to one of the tables.  Export forward engineer script.  When you run the script, you'll get the error 1064 (42000): You have an error in your SQL syntax; check the namual that corresponds to your MySQL sever version for the right syntax to user near [shows the bad lines of code].

Here is a sample of the statements and error message:

mysql> USE `mydb` ;
Database changed
mysql>
mysql> -- -----------------------------------------------------
mysql> -- Table `mydb`.`Test`
mysql> -- -----------------------------------------------------
mysql> CREATE  TABLE IF NOT EXISTS `mydb`.`Test` (
    -> )
    -> ENGINE = InnoDB
    -> COMMENT = 'These are my test comments.';
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 ')
ENGINE = InnoDB
COMMENT = 'These are my test comments.'' at line 2
mysql>
mysql>
mysql>
mysql> SET SQL_MODE=@OLD_SQL_MODE;
Query OK, 0 rows affected (0.00 sec)

mysql> SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
Query OK, 0 rows affected (0.00 sec)

mysql> SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
Query OK, 0 rows affected (0.00 sec)

mysql> use mydb;
Database changed
mysql> show tables;
Empty set (0.00 sec)

mysql>

Suggested fix:
Update the script creator to produce the correct syntax for comments.
[10 Jun 2010 13:59] Johannes Taxacher
Hi Daniel,
I'd rather say the problem with given snippet is that there are no columns defined in the table and that's what the server is refusing. Can you check again? Otherwise i cant reproduce the problem.
thank in advance
[14 Jun 2010 15:38] Daniel Davis
The Script generated by workbench

Attachment: trial.sql (application/octet-stream, text), 647 bytes.

[14 Jun 2010 15:44] Daniel Davis
I checked and I am creating a table.  I've included the script I generated after creating a test case.  I tried to include my mwb file, but it's too big to upload here.
[16 Jun 2010 12:28] Valeriy Kravchuk
Why you had NOT defined any column for the table? Do you see any column defined for it in .mwb file?
[16 Jun 2010 15:01] Daniel Davis
Oops.  You're right.  I forgot to include rows in my test case.  I'm Now I'm also unable to reproduce the problem now that I've added rows.
[16 Jun 2010 23:18] MySQL Verification Team
Could you please re-open this bug report when you can provide a repeatable test case. Thanks in advance.
[17 Jul 2010 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".