[Dbix-class] Strange (expected?) inflate_column and update behaviour

Matt S Trout dbix-class at trout.me.uk
Thu Mar 23 02:17:30 CET 2006


Michele Beltrame wrote:
> Hello!
> 
> In a table schema of mine I have:
> 
> __PACKAGE__->inflate_column('published', {
>     inflate     => sub { time_db2obj(shift) },
>     deflate     => sub { time_obj2db(shift) },
> });
> 
> I noticed that the deflate method is NOT called when I use update() on a
> resultset an pass data like this:
> 
> $c->model('Dbs')->resultset('MyTable')->update(
>     field1     => 'val',
>     field2     => 'val'
>     published  => $datetime_object
> );

This does a direct UPDATE and doesn't obey inflate_column; that's on the 
result class only, not the resultset.

> At least, it seems like thid because "cannot compare a DateTime to a
> scalar" is thrown. The deflate method IS however regularly called if I
> do like this:
> 
> $c->model('Dbs')->resultset('MyTable')->published($datetime_object);
> $c->update();

That shouldn't work at all. Did you paste it wrong?

If you mean update() on an object I believe this is fixed in the latest dev 
release.

-- 
      Matt S Trout       Offering custom development, consultancy and support
   Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Dbix-class mailing list