Bug #38421 Column default value cannot be changed from NULL to other value
Submitted: 28 Jul 2008 23:12 Modified: 30 Jul 2008 17:55
Reporter: Alex Saavedra Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Workbench Severity:S3 (Non-critical)
Version:5.0.23 SE OS:Windows (SP3)
Assigned to: CPU Architecture:Any

[28 Jul 2008 23:12] Alex Saavedra
Description:
As part of a large database design, the MySQL validation tool (Model >> Validation - MySQL) reported several design errors, such as "NULL default value for not-null column".

So we fixed such error designs changing all default values for not-null columns.

However, the specified values (DEFAULT '', or DEFAULT 'ABC') were not properly exported by any of the available tools, and were always reported as "DEFAULT NULL".

We attach an .mwb file containing only one of our tables, yet the error persists.

How to repeat:
1. open the attached test.mwb file
2. go to Model >> Validation (MySQL) >> Validate all
3. The output panel states the following 2 errors:

  NULL default value for not-null column 'companyId' in table 'tblAgent'.
  NULL default value for not-null column 'creditLimit' in table 'tblAgent'.

4. However if you check both column definitions, you can see that default value for tblAgent.companyId is 'ABC', and that default value for tblAgent.creditLimit is '0'

You can also follow the following steps:
1. open the attached test.mwb file
2. go to File >> Export >> Forward Engineer SQL CREATE Script
3. proceed with default selections
4. the last step shows the following error:

Error 1067: Invalid default value for 'companyId'

-- -----------------------------------------------------
-- Table `oc`.`tblAgent`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `oc`.`tblAgent` (
  `agentId` CHAR(32) NOT NULL ,
  `companyId` CHAR(32) NOT NULL DEFAULT NULL ,
  `bankAccount` VARCHAR(30) NULL DEFAULT NULL ,
  `active` TINYINT(1) NULL DEFAULT 1 ,
  `deleted` TINYINT(1) NULL DEFAULT 0 ,
  `creditLimit` INT(10) NOT NULL DEFAULT NULL ,
  `paymentType` VARCHAR(20) NULL DEFAULT NULL ,
  PRIMARY KEY (`agentId`) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_general_ci
SQL script execution finished: statements: 8 succeeded, 1 failed

As you can see, the 'companyId' field has a DEFAULT NULL clause.
[28 Jul 2008 23:13] Alex Saavedra
Database design project

Attachment: test.mwb (application/x-zip-compressed, text), 4.16 KiB.

[29 Jul 2008 3:47] Valeriy Kravchuk
Thank you for a bug report. Verified just as described.
[30 Jul 2008 17:55] Johannes Taxacher
Even though it doesn't really like a duplicate of http://bugs.mysql.com/bug.php?id=37574 the source of the problem was the same. the fix will be in 5.0.24