Bug #60774 WB generates "Error 1064: You have an error in your SQL syntax"
Submitted: 6 Apr 2011 10:49 Modified: 9 Jan 2015 16:16
Reporter: Stuart Hendrick Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Workbench: Modeling Severity:S3 (Non-critical)
Version:5.2.33 (MySQL Server version 5.5.9) OS:Windows (W7 64-bit)
Assigned to: CPU Architecture:Any
Tags: 1064, comment, forward engineer

[6 Apr 2011 10:49] Stuart Hendrick
Description:
Forward-engineering a model.  Second table to be created fails with the following error:

ERROR: Error 1064: 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 ' 

COMMENT = 'Subject area within a subset - e.g. Finial Height, Leverages' /* co' at line 4

[Thanks WB, that's not MY syntax, it's yours!]

Irrelevant but interesting: 
The "co" at the end is a truncation of "comment truncated", and by any count that I can devise it's not line 4.  I first tried shortening the comment, taking out anything that might be a special character, all to no effect.  Anyway the previous table, including a similar comment, was created perfectly well.

Relevant: 
The problem seems to be that for all tables after the first, any Comment line is preceded by a comma in the script, and this comma causes FE to fail.  Here's the early part of my script:

-- -----------------------------------------------------
-- Table `sur_local`.`Sponsor`
-- -----------------------------------------------------

DROP TABLE IF EXISTS `sur_local`.`Sponsor` ;

CREATE  TABLE IF NOT EXISTS `sur_local`.`Sponsor` (
  `SponsorID` INT NOT NULL AUTO_INCREMENT ,
  `SponsorCode` VARCHAR(20) NOT NULL ,
  `SponsorName` VARCHAR(50) NOT NULL ,
  PRIMARY KEY (`SponsorID`) )
COMMENT = 'Identiifies an organisation that coordinates subsets - e.g. ' /* comment truncated */ ;

CREATE UNIQUE INDEX `SponsorID_UNIQUE` ON `sur_local`.`Sponsor` (`SponsorID` ASC) ;

-- -----------------------------------------------------
-- Table `sur_local`.`Theme`
-- -----------------------------------------------------

DROP TABLE IF EXISTS `sur_local`.`Theme` ;

CREATE  TABLE IF NOT EXISTS `sur_local`.`Theme` (
  `ThemeID` INT NOT NULL ,
  `ThemeName` VARCHAR(20) NOT NULL ,
  PRIMARY KEY (`ThemeID`) ),  ######## bug - the comma should not be here ####
COMMENT = 'Subject area within a subset - e.g. Finial Height, Leverages' /* comment truncated */ ;

CREATE UNIQUE INDEX `ThemeID_UNIQUE` ON `ldms_local`.`Theme` (`ThemeID` ASC) ;

Workround - edit out all those extraneous commas. 

How to repeat:
FE a model that includes more than one commented table
[6 Apr 2011 11:26] Valeriy Kravchuk
Please, send the problematic .mwb file and provide the exact server version, 5.x.y, used.

I've got the code you described (extra comma before COMMENT for second table):

SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';

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

-- -----------------------------------------------------
-- Table `mydb`.`table1`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`table1` (
  `idtable1` INT NOT NULL ,
  `c1` VARCHAR(45) NULL ,
  PRIMARY KEY (`idtable1`) )
ENGINE = InnoDB
COMMENT = 'this is a long long comment like this 1234567890 1234567890 ' /* comment truncated */ ;

-- -----------------------------------------------------
-- Table `mydb`.`table2`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`table2` (
  `idtable2` INT NOT NULL ,
  `c1` VARCHAR(45) NULL ,
  PRIMARY KEY (`idtable2`) )
ENGINE = InnoDB, 
COMMENT = 'this is another long long comment like this 1234567890 12345' /* comment truncated */ ;

SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;

But this script executed successfully on both 5.0.91 and 5.5.10. I think the problem may be related to the exact comment text in your case.
[6 Apr 2011 11:37] Stuart Hendrick
MySQL Server version 5.5.9
[6 Apr 2011 12:21] MySQL Verification Team
Thank you for the feedback.