In Kohana 3.2, when you overwrite the function 'values' of the ORM, and then do something like:
public function values(array $values, array $expected = NULL) {
if($values['a_column'] == "") $values['a_column'] = NULL;
return parent::values($values);
}
the NULL value will be transformed into an empty string anyway, which is not the behaviour I want. Anyone knows a workaround? I couldn't find anything in the documentation or on the web...
I discovered the answer to this. Just use a filter in your model, like so:-
public function filters()
{
return array(
'initial_assessment_date' => array(
array(function($value) {
return (!$value) ? NULL : $value;
})
)
);
}