rails/rails — pull request #7780 by dylanahsmith (2012-09-28 19:25:25+00:00)
Title: activerecord: Avoid mysql non-null text column defaulting to empty string

The mysql database adaptor assumes that non-null text columns behave as if the default value is an empty string. This is the default behaviour for mysql connections, but putting the connection in strict mode with `SET SQL_MODE='STRICT_ALL_TABLES'` makes like other databases, where the default value is NULL so the value must be specified.

The mysql adaptor defaults to using this strict mode, although it can be disabled with setting `strict: false` in the database configuration. However, the mysql adapter has a hack based on non-strict mode behaviour to detect an empty string default value. So even though strict mode is used, this hack is continuing non-strict mode behaviour within strict mode.

I propose just removing this hack to mimic the non-strict behaviour to make its behaviour consistent with other databases. This is what this pull request does.