Re: DBI 1.15 subclassing bug! -------------------------------------------------------------------------------- To: "dbi-users" Subject: Re: DBI 1.15 subclassing bug! From: "Phil R Lawrence" Date: Mon, 9 Apr 2001 11:40:39 -0400 Cc: "Tim Bunce" Delivered-To: mailing list dbi-users@perl.org Mailing-List: contact dbi-users-help@perl.org; run by ezmlm References: <00a501c0bede$2b70be00$5b34b480@lehigh.edu> <20010407000509.F20472@ig.co.uk> -------------------------------------------------------------------------------- "Tim Bunce" wrote: > On Fri, Apr 06, 2001 at 05:11:38PM -0400, Phil R Lawrence wrote: > > Uncaught exception from user code: > > DBI->disconnect is not a DBI method... > I wouldn't want to call you a beginner, but somewhere, for some > reason, you're executing "DBI->disconnect" or "$foo->disconnect" > where $foo contains "DBI". You were kind to not call me a beginner! Nonetheless, the issue was a screwed up @ISA ordering. See below for the bug. I'm glad you added the code to make DBI->disconnect blow up in DBI 1.15. I learned a bit more about inheritance as a result. Thanks, Phil R Lawrence package STORIT; use SUBCLASS_DBI; use vars qw( @ISA ); @ISA = qw ( SUBCLASS_DBI ); sub new { my $proto = shift; my $class = ref($proto) || $proto; my $s = $class->test_connect or die; return $s; } #============================================================== package STORIT::db; use vars qw( @ISA ); @ISA = qw( STORIT SUBCLASS_DBI::db ); # ^^^^^^ # this caused disconnect invocation to be first looked # for as a DBI method (due to STORIT's @ISA) instead # of as a SUBCLASS_DBI::db method (which would have # correctly resolved as a DBI::db method). #============================================================== package STORIT::st; use vars qw( @ISA ); @ISA = qw(SUBCLASS_DBI::st);