[Dbix-class] CDBI Compatability Issue: Iterators

Matt S Trout dbix-class at trout.me.uk
Fri Aug 19 21:41:07 CEST 2005

On Fri, Aug 19, 2005 at 10:46:41AM -0400, Christopher H. Laco wrote:
> That also worked but brought up another problem.
> DBIx::Class::Resultset->next calls
> DBIx::Class::Row->_row_to_object($self->{cols}, \@row)
> DBIx::Class::Row->_row_to_object calls
> $class->new(\%vals) on the child object class to be created, which in my 
> case has it's own custom ->new() method.

The thing being, ->create calls ->new so unless your ->new is compatible
you're still going to have problems.

> This is different from Class::DBI::Iterator; whos next method calls 
> $self->class->construct($use)

Yep. I should really add a "sub construct { shift->new(@_); }" to emulate
> So, how do we fix this? can _row_to_object have and extra paramater 
> specifying the constructore method?

Providing a single constructor method with the standard name for said
is critical to allow people to override/tweak/whatever object construction
in a standard way. Your problem as I see it is that Class::DBI behaves
non-standardly in terms of object construction and you've mistakenly assumed
whatever other libraries you use will make the same design error :)

     Matt S Trout           Website: http://www.shadowcatsystems.co.uk
  Technical Director        E-mail:  mst (at) shadowcatsystems.co.uk
Shadowcat Systems Ltd.

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

More information about the Dbix-class mailing list