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

Matt S Trout dbix-class at trout.me.uk
Thu May 10 20:22:59 GMT 2007


On Thu, May 10, 2007 at 11:10:49AM -0700, John Napiorkowski wrote:
> 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)."

That should never happen - a column that's inflated to a datetime will
have an accessor that calls set_inflated_column, not set_column - which will
deflate the value, thus resulting in the comparison being made between two
strings.

This is why you should almost always use the accessor methods rather than
calling set_column directly - it's a public method primarily for subclassing
purposes, not for you to call because you've forgotten $obj->$col($val)
works.

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director    Want a managed development or deployment platform?
 Shadowcat Systems Ltd.  Contact mst (at) shadowcatsystems.co.uk for a quote
http://chainsawblues.vox.com/             http://www.shadowcatsystems.co.uk/ 



More information about the Dbix-class mailing list