Bug #37184 Table editor generates invalid alter table after changing NULL column to NOT NUL
Submitted: 4 Jun 2008 9:18 Modified: 26 May 2009 13:19
Reporter: Janek Bogucki Email Updates:
Status: Unsupported Impact on me:
None 
Category:MySQL Query Browser Severity:S3 (Non-critical)
Version:1.2.12 OS:Linux (Kubuntu 8.04)
Assigned to: CPU Architecture:Any

[4 Jun 2008 9:18] Janek Bogucki
Description:
The table editor generates this sql after changing a nullable column to NOT NULL and deleting the DEFAULT value:

ALTER TABLE `cert`.`t2` MODIFY COLUMN `i` INTEGER  NOT NULL DEFAULT NULL;

The above sql must be manually changed to

ALTER TABLE `cert`.`t2` MODIFY COLUMN `i` INTEGER  NOT NULL;

to allow it to be applied.

How to repeat:
1. Create a new table by right clicking on the schema object.

2. Name the table

3. Create a column named i, type INT, "Not NULL" unchecked. Do not enter a DEFAULT value

4. Select the line underneatch column i and  click "Apply Changes"

5. Close the table editor

6. Edit the table from the table list by right clicking and choosing "Edit...". Note that column i has a DEFAULT of NULL. This is expected.

7. Select column i and check "Not NULL".

8. Delete all the characters in the "Default Value" box.

9. Select the line underneatch column i and click "Apply Changes"

10. Note the inclusion of "DEFAULT NULL" in the generated ALTER TABLE statement even though the "Default Value" box is empty:

  ALTER TABLE `cert`.`t3` MODIFY COLUMN `i` INTEGER  DEFAULT NULL;

Suggested fix:
Make the sql generation honour the value in "Default Value".

Replace the inobvious greying of the NULL button to the right of the "Default Value" box with a clearer way of showing that "DEFAULT NULL" is selected. I only noticed this was happening while writing this bug report. At the very least ungrey the button when the text in the "Default Value" box is not NULL.
[4 Jun 2008 9:19] Janek Bogucki
Added version and OS details.
[18 Jun 2008 13:38] MySQL Verification Team
Thank you for the bug report. I experienced different behavior the alter statement  is correct but when applying changes it is displayed the NULL default clause.
[27 Oct 2008 4:13] Jared S
Bug should be marked duplicate of http://bugs.mysql.com/bug.php?id=36076
[26 May 2009 13:19] Susanne Ebrecht
Many thanks for writing a bug report. We are on the way to implement full functionality of MySQL Query Browser into MySQL Workbench. Unfortunately you are using an unsupported platform. More informations about supported platforms you will find here:

http://www.mysql.com/support/supportedplatforms/tools.html

More informations about MySQL Workbench you will find here:

http://dev.mysql.com/workbench/