DBIx::Class::InflateColumn bug (was Re: [Dbix-class] RFC: Inflating user-supplied values)

Matt S Trout dbix-class at trout.me.uk
Tue May 8 01:38:16 GMT 2007


On Mon, May 07, 2007 at 05:27:42PM -0400, Jason Kohles wrote:
> What this means is that this will work as expected:
> 
> $obj->col( '$10.00' );
> print ref( $obj->col )."\n"; # will print Data::Currency
> 
> However, this will _not_ work as expected:
> 
> $obj->col( '$10.00' );
> $obj->update;
> 
> The reason the second one doesn't work has to do with the inner  
> workings of get_inflated_column and set_inflated_column.

Yes, this should never go through the inflation code.

Either you pass the DB value or you pass the appropriate object - in this
case a Data::Currency object.

The ability to take DB values here is just a convenience for when you're
interacting directly with the DB's world-view; your application should
-always- pass an appropriate object for this sort of case.

Providing an inflator at the form layer to produce an appropriate object
for the interface your domain model is presenting as you're currently doing
is the correct solution, and providing a hack for poor usage at the DBIC
layer as your 'check' addition proposes isn't.

Sometimes good architecture is a little bit more typing :)

-- 
      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://www.shadowcatsystems.co.uk/ 



More information about the Dbix-class mailing list