An ActiveRecord-Object refuses to save instead an exception is thrown if a member which corrosponds with a column that has a default value in the mysql db is not set.
I've found the code that causes the error in TActiveRecordGateway.php:
if(!$column->getAllowNull() && $value===null && !$column->hasSequence())
{
throw new TActiveRecordException(
'ar_value_must_not_be_null', get_class($record),
$tableInfo->getTableFullName(), $name);
}
The logic behind this code seems incorrect to me as it does not take a default value into account. I've patched it the following way
297c297,298
< if(!$column->getAllowNull() && $value===null && !$column->hasSequence())
---
> if(!$column->getAllowNull() && $value===null && !$column->hasSequence()
> && !$column->getDefaultValue())
For an example of the bug please see my previous thread:
http://www.pradosoft.com/forum/index.php/topic,10599.0.htmlPlease consider to apply the patch to svn if you don't see any mistakes.
Greetings acron
System:
Webserver: Apache2 with PHP Version 5.2.4-2ubuntu5.2
Prado: prado-3.1.2.r2448
DB: 5.0.51a-3ubuntu5.1