[Dbix-class] Bug: update_or_create() and auto-inflate/deflate
Bernhard Graf
dbic1 at augensalat.de
Wed May 10 13:23:44 CEST 2006
I have a table class with a 'created' column that is defined as:
__PACKAGE__->inflate_column('created', {
inflate => sub { DateTime::Format::MySQL->parse_date(shift) },
deflate => sub { DateTime::Format::MySQL->format_date(shift) },
});
In my Application the call looks basically:
$date = DateTime->new(...);
$rs->update_or_create({
id => $id,
other => $other_data,
created => $date,
});
Everything works if row is created.
But the next time (update) it fails saying:
Cannot compare a datetime to a regular scalar at /usr/lib/perl5/vendor_perl/5.8.5/x86_64-linux-thread-multi/DateTime.pm line 1395.
It seems that one of the dates to compare is a scalar while the other is
a DateTime object (DateTime overloads comparison operators, so compare
operation end in DateTime->compare()).
To work correctly, update_or_create() should compare both dates in
deflated state, right?
--
Bernhard Graf
More information about the Dbix-class
mailing list