Bug #23079 CHAR shows as CHAR(0) in SQL create script
Submitted: 7 Oct 2006 21:46 Modified: 10 Oct 2006 23:18
Reporter: Matthew Williams Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Workbench Preview Severity:S3 (Non-critical)
Version:1.1.3 alpha OS:Windows (XP Home SP2)
Assigned to: CPU Architecture:Any
Tags: char, create script

[7 Oct 2006 21:46] Matthew Williams
Description:
Creating a CHAR column appears correctly in Workbench. When exporting and SQL create script it shows as CHAR(0) which is not correct.

How to repeat:
Insert a table.
Edit the table and add a CHAR column.
Export the SQL create script and see that it shows as CHAR(0).
----snip----
CREATE TABLE `test`.`table_01` (
  `idtable_01` CHAR(0) CHARACTER SET  COLLATE  NOT NULL,
  PRIMARY KEY (`idtable_01`)
)
---snip---

Suggested fix:
Reproduce the Datatype as entered when exporting the SQL create script.
[9 Oct 2006 23:22] MySQL Verification Team
Thank you for the bug report. I was unable to repeat with version 1.1.3:

-- ----------------------------------------------------------------------
-- MySQL GRT Application
-- SQL Script
-- ----------------------------------------------------------------------

SET FOREIGN_KEY_CHECKS = 0;

CREATE DATABASE IF NOT EXISTS `test`
  CHARACTER SET latin1;
-- -------------------------------------
-- Tables

DROP TABLE IF EXISTS `test`.`table_01`;
CREATE TABLE `test`.`table_01` (
  `idtable_01` CHAR(20) CHARACTER SET  COLLATE  UNSIGNED NOT NULL,
  PRIMARY KEY (`idtable_01`)
)
ENGINE = InnoDB
CHARACTER SET latin1 COLLATE latin1_swedish_ci;

SET FOREIGN_KEY_CHECKS = 1;

-- ----------------------------------------------------------------------
-- EOF
[10 Oct 2006 23:18] Matthew Williams
Clarification: only occurs when you use “CHAR” with no parentheses “(x)” afterwards. This would be equivalent to saying “CHAR(1)” but it is a valid statement in MySQL to say “`id_table1` CHAR NOT NULL` without including the “(1)”.