Bug #31131 Add SQL MODE (like Oracle) that will treat an Empty String as a NULL
Submitted: 21 Sep 2007 14:57
Reporter: Chris Calender Email Updates:
Status: Verified Impact on me:
Category:MySQL Server: General Severity:S4 (Feature request)
Version:All OS:Any
Assigned to: CPU Architecture:Any
Tags: empty string, null, Oracle, sql mode, SQL_MODE

[21 Sep 2007 14:57] Chris Calender
Add a SQL MODE which treats empty strings as NULLs.

This is what Oracle currently does (whether it is a bug or not, and whether they'll ever fix it or not).

Basically, Oracle stores empty strings as NULL internally, or throws an error if it receives an empty string on a non-nullable column.

This would make a good addition to the current "ORACLE" sql_mode also.

How to repeat:

Suggested fix:
[21 Sep 2007 16:09] Chris Calender
This should be it's own SQL MODE (for example, EMPTY_STRING_AS_NULL).  And then this new mode, EMPTY_STRING_AS_NULL should be included with the "ORACLE" SQL MODE as well.

Also, as a unit test, one should be able to insert or update a non-nullable string column with an empty string, and receive an error if the new mode (EMPTY_STRING_AS_NULL) is enabled, and one is using STRICT_TRANS_TABLES (i.e., the fact that the empty string is the "default default" for non-nullable string columns when you're not running in STRICT_TRANS_TABLES might imply that this mode is only applicable when STRICT_TRANS_TABLES is enabled).
[21 Sep 2011 9:24] MySQL Verification Team
http://bugs.mysql.com/bug.php?id=62482 marked as duplicate of this one.