[Dbix-class] Pointless update on a date field
Richard Jones
ra.jones at dpw.clara.co.uk
Fri Sep 7 13:51:32 GMT 2007
In my Catalyst app, a method is looking for a partial match on an
existing record, then updating the record with missing data, ie
my $user = $c->model('Schema::User');
if ( my $partial_match = $user->find( $search_for_missing{gender} ) ) {
# record matched on last_name, first_name, dob, etc, but ! gender
$user->update( $form_data ); # should just update gender field
}
All appears to be working fine, but I notice from the debugging SQL that
the date field (dob) is always updated, even though the submitted value
is identical to the stored value of the retrieved record, ie:
UPDATE users SET dob = ?, gender = ? WHERE ( id = ? )
I assume this is because I am using InflateColumn::DateTime on the date
fields. If I dump $user->last_name I get a scalar, but $user->dob gives
me a complex data structure (the DateTime object?). But I'm not sure why
it is trying to update the date field. Presumably it's harmless, as the
update would silently fail anyway?
The question is, am I correct, and do I need to worry about it?
--
Richard Jones
More information about the DBIx-Class
mailing list