[Dbix-class] Trouble updating columns (possible bug or not enough DWIM)

John Napiorkowski jjn1056 at yahoo.com
Thu May 10 19:10:49 GMT 2007


Hi,

I may have an issue with the way Row.pm's set_column
method performs it's comparison with possible old
values for the purposes of marking a column dirty.

I'm running a filter using DBIx::Class::Validation to
try and guess a reasonable datetime object out of
whatever the user submits to a form.  I noticed that
when you update a column $Row->set_column does a
comparison to any old values for the purposes of
marking something dirty.

However if the old value is a string and the new one
is a DateTime object I get the following error:

"A DateTime object can only be compared to another
DateTime object (DateTime=HASH(0xab3854c), tomorrow)."

I'm guessing this could be trouble for things other
than DateTime objects that are trying to do
overloading.

The way we are comparing values in the mentioned code
is oriented around scalars for the most part:

  $self->{_dirty_columns}{$column} = 1
    if (defined $old ^ defined $ret) || (defined $old
&& $old ne $ret);

For my case simply quoting the values to stringify
solved my problem but would like the opinion of the
list as to if this is good enough, like:

  $self->{_dirty_columns}{$column} = 1
    if (defined $old ^ defined $ret) || (defined $old
&& "$old" ne "$ret"); #Stringify

Maybe something like Data::Compare would be better? 
Would slow it down for comparing big objects though.

Please let me know if my email continues to not play
nice with your mail client.

Thanks!
John Napiorkowski


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Dbix-class mailing list