Subject: | Problems with multiple tagged columns |
I'm using DBIx::Class::Timestamp for implementing a pair of fields in my table. The
fields, called created_on and modified_on should represent a creation date and a modification date.
Thus, I have something like that in my Result class:
__PACKAGE__->load_components("InflateColumn::DateTime", "TimeStamp");
__PACKAGE__->add_columns(
"id",
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
"title",
{ data_type => "varchar", is_nullable => 0, size => 255 },
"description",
{ data_type => "text", is_nullable => 0 },
"created_on",
{
data_type => "datetime",
datetime_undef_if_invalid => 1,
is_nullable => 0,
set_on_create => 1,
},
"modified_on",
{
data_type => "datetime",
datetime_undef_if_invalid => 1,
is_nullable => 0,
set_on_create => 1,
set_on_update => 1,
},
);
After creation of an entry in the corresponding table, and prior to any update, I'd expect to have identical created_on and modified_on fields. However, this do not happens every time. Because of the way DBIx::DyamicDefault works, get_timestamp is called two times, one for each column, and this can (and will using HiRes time) give two different values.
Worst, given how DBIx::DyamicDefault determines the order in which to apply the dynamic defaults, we could have modified_on < created_on for a newly created object.