[Dbix-class] inheritance problem?

Matt S Trout dbix-class at trout.me.uk
Tue Sep 26 16:48:40 CEST 2006


Alan Humphrey wrote:
> Actually, looking at this again, I'm pretty sure it's right: neither
> DBIx::Class::Storage::DBI::Sybase::MSSQL nor its parent classes
> override _execute.
> 
> NoBindVars does its work in _prep_for_execute, so I'd expect that a
> ->can on that would refer there.
> 
> I found the problem, but I don't know what the solution is.
> 
> The problem is in the multiple inheritance of Sybase::MSSQL:
> 
> use base qw/DBIx::Class::Storage::DBI::MSSQL
> DBIx::Class::Storage::DBI::Sybase/;
> 
> When _execute is called (which is what NoBindVars overrides) Perl looks
> first in DBI::MSSQL.  Having no luck there, Perl goes *up* a level to DBI
> finds the method and stops.  (Thanks to Conway's "Object Oriented Perl" for
> pointing this out.  He says it's "left-most ancestor wins".)
> 
> If you swap the class names in the use statement:
> 
> use base qw/DBIx::Class::Storage::DBI::Sybase
> DBIx::Class::Storage::DBI::MSSQL/;
> 
> Then the correct _execute is found.  However, you now get the wrong version
> of last_insert_id and build_datetime_parser (methods overridden by
> DBI::MSSQL).
>  
> So now the question is: how do you do multiple inheritance in Perl such that
> both parent classes can override the grandparent?

Try adding

use Class::C3;

to DBIx::Class::Storage::DBI::Sybase::MSSQL

-- 
      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