Subject: | set_inflated_columns do not clear columns |
When you have an inflated column, such as
"date_message",
{
data_type => "DATE",
default_value => "SYSDATE",
is_nullable => 1,
size => 19,
},
using DBIx::Class::InflateColumn::DateTime,
the only way to clear the date_message column
is to use $obj->date_message(undef) or
$obj->set_inflated_column('date_message' => undef).
BUT if you do $obj->set_inflated_columns({date_message => undef});
it WILL NOT clear the column because if ignores all non scalar values,
cf the line "if (ref $upd->{$key}) {" in the set_inflated_columns
function.
So IMHO this is plainly wrong because one thinh that these two calls are
equivalent, and moreover the values are silently ignored.
sub set_inflated_columns {
my ( $self, $upd ) = @_;
foreach my $key (keys %$upd) {
if (ref $upd->{$key}) {
my $info = $self->relationship_info($key);
my $acc_type = $info->{attrs}{accessor} || '';
if ($acc_type eq 'single') {
my $rel = delete $upd->{$key};
$self->set_from_related($key => $rel);
$self->{_relationship_data}{$key} = $rel;
}
elsif ($acc_type eq 'multi') {
$self->throw_exception(
"Recursive update is not supported over relationships of type
'$acc_type' ($key)"
);
}
elsif ($self->has_column($key) && exists
$self->column_info($key)->{_inflate_info}) {
$self->set_inflated_column($key, delete $upd->{$key});
}
}
}
$self->set_columns($upd);
}