[Dbix-class] Issue with DBIx::Class::TimeStamp
Bernhard Graf
dbic3 at augensalat.de
Sat Sep 6 19:30:49 BST 2008
/me wrote:
> Wouldn't it be better if $self->is_changed is consulted first in
> DBIx::Class::TimeStamp?
I took DBIx::Class::TimeStamp version 0.05 (the one w/o DynamicDefault)
and modified the code to DWIM:
sub update {
my ($self, $upd) = @_;
# needed to get_dirty_columns()
$self->set_inflated_columns($upd) if $upd;
my %dirty = $self->get_dirty_columns();
if (%dirty) {
my $now = $self->get_timestamp();
my @columns = @{ $self->__column_timestamp_triggers()->{on_update} };
foreach my $column ( @columns ) {
next if exists $dirty{ $column };
my $accessor = $self->column_info($column)->{accessor} || $column;
$self->$accessor($now);
}
}
$self->next::method;
}
Even if it seems to work correctly, I'm still not really happy with it,
because it copies some innards of DBIx::Class::Row::update(), so I'm not
sure if it really behaves right in every case and in future versions of
DBIC.
--
Bernhard Graf
More information about the DBIx-Class
mailing list