Skip to content

Magento 1.9 / OpenMage Impossible To Save NULL value to smallint / int database column

After what seems like hours of research, it seems that it’s impossible to save a null value to a database column of type int even when it’s nullable and defaults to null when the object value is an empty string.

In Varien_Db_Adapter_Pdo_Mysql::prepareColumnValue, it completely ignores a column that’s unsigned because it appends “unsigned”, like “int unsigned”. So when $column['DATA_TYPE'] is analysed it’s ignored.

This is critical because we need an empty value to resolve to 0 or null (either would work.

Also, in Mage_Core_Model_Resource_Abstract::_prepareDataForTable, if we can convert '' or ‘0’ to NULL, line 213 would set it to NULL.

Has anyone else found this to be an issue?