Bug #51416 Export function creates multiple semicolons for views
Submitted: 23 Feb 2010 10:53 Modified: 26 Mar 2010 16:19
Reporter: Kai Sautter (Basic Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench: SQL Editor Severity:S3 (Non-critical)
Version:5.1.18a, 5.2.16 OS:Any
Assigned to: Alexander Musienko CPU Architecture:Any
Tags: qc

[23 Feb 2010 10:53] Kai Sautter
Description:
The export function of MySQL Workbench imperatively adds a semicolon (";") at the end of the create statement for a view. If a semicolon has already been added to the views SQL statement (DDL Property of the view) in design mode, this will result in two semicolons at the end of the view's create statement in the export file.

As deleting the ";" in the DDL property fixes the property, there is a work around.

How to repeat:
1) Create a view in the MySQL Model
2) set the DDL property e.g. to "select * from foo;" (including semicolon).
3) Execute the Export function: File --> Export --> Forward Engineer SQL CREATE Script
4) Include the view for export
5) Review the generated SQL statement

If the ";" is deleted from the DDL property, the SQL statement generated by the "Forward Engineer..." Functionality looks ok.

Suggested fix:
Add a checking routine within the export function, that eliminates the last character of the DDL property, if it is a ";".
[23 Feb 2010 11:19] Valeriy Kravchuk
Thank you for the bug report. Verified just as described. The following cocde is generated by WB 5.2.16:

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
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 ;

-- -----------------------------------------------------
-- Table `mydb`.`table1`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `mydb`.`table1` (
  `idtable1` INT NOT NULL ,
  `c1` VARCHAR(45) NULL ,
  PRIMARY KEY (`idtable1`) )
ENGINE = InnoDB;

-- -----------------------------------------------------
-- Placeholder table for view `mydb`.`view1`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`view1` (`idtable1` INT, `c1` INT);

-- -----------------------------------------------------
-- View `mydb`.`view1`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`view1`;
CREATE  OR REPLACE VIEW `mydb`.`view1` AS select * from table1;
;

SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
[23 Mar 2010 14:11] Johannes Taxacher
fixed in repository
[26 Mar 2010 16:19] Tony Bedford
An entry has been added to the 5.2.17 changelog:

When a model with a view was exported using File, Export, Forward Engineer SQL CREATE Script, a semi-colon was added to the end of the CREATE VIEW statement, even if one was already present from the view code entered.