energylab / gacela

An open-source PHP Data Mapper ORM and Domain Framework built on PHP 5.3
gacelaphp.com
MIT License
29 stars 6 forks source link

Default boolean values fail model validation #26

Closed bmidget closed 12 years ago

bmidget commented 12 years ago

On develop branch

When I have a model/mapper for a mysql table with a boolean that is not nullable but has a default value of "0", the model fails Gacela's 'NULL' validation rule unless I specifically set the field value.

This doesn't work:

// This example table has field is_admin which is a TINYINT(1) NOT NULLABLE  dafault "0"
$m = new User_Model;
$m->save([
    'username' => $username
]);

This does:

$m = new User_Model;
$m->save([
    'username' => $username,
    'is_admin' => 0
]);

I haven't explored whether this happens for other non-nullable field types with default values.