--- Matt S Trout <[EMAIL PROTECTED]> wrote: > 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.
The code I have dies on ->create_related(...) because the DBIx::Class::Validation profile I have defines a filter that converts plaintext to a datetime object (or tries very hard). DBIC::Validation automatically updates the row if you set that behavior, and it's calling set_column. I did a quick hack to DBIC::Validation to change: $self->set_column($_, $result->valid($_)) for ($result->valid); To: $self->$_($result->valid($_)) for ($result->valid); And behold! That solved the problem! Thanks Matt. I'll offer a patch to the maintainer of DBIC::Validation. --John __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com _______________________________________________ List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class Wiki: http://dbix-class.shadowcatsystems.co.uk/ IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/ Searchable Archive: http://www.mail-archive.com/[email protected]/
