Skip Menu |

This queue is for tickets about the DBI CPAN distribution.

Report information
The Basics
Id: 1797
Status: resolved
Priority: 0/
Queue: DBI

People
Owner: Nobody in particular
Requestors: troy.tausend [...] target.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.30
Fixed in: (no value)



Subject: Cannot set RootClass attribute to a package in the same file
Given this example: --START-- package Foo::DBIx; our @ISA = qw(DBI); package Foo::DBIx::db; our @ISA = qw(DBI::db); package Foo::DBIx::st; our @ISA = qw(DBI::st); package main; use DBI; $dbh = DBI->connect( 'dbi:Oracle:', 'scott', 'tiger', { RootClass => 'Foo::DBIx' } ); ---END--- DBI (v1.30) throws back the following error: Can't locate Foo/DBIx.pm in @INC (@INC contains: /home/prod/perl5/lib/5.6.1/aix /home/prod/perl5/lib/5.6.1 /home/prod/perl5/lib/site_perl/5.6.1/aix /home/prod/perl5/lib/site_perl/5.6.1 /home/prod/perl5/lib/site_perl .) at /home/prod/perl5/lib/site_perl/5.6.1/aix/DBI.pm line 776. ...propagated at /home/prod/perl5/lib/site_perl/5.6.1/aix/DBI.pm line 780. The DBI documentation says that this should be a non-fatal error: [...] that using an explicit RootClass attribute will make the DBI automatically attempt to load a module by that name (and not complain if such a module can't be found) [...] and code in DBI.pm looks like it tries to ignore this type of error: sub _load_module { (my $module = shift) =~ s!::!/!g; eval { require $module.'.pm'; }; return 1 unless $@; return 0 if $@ =~ /^\b\@INC\b/; die; # propagate $@; } But the regex used doesn't match the error thrown back by perl 5.6.1 (the regex itself may be flawed, since '@' !~ /\w/). If Foo::DBIx is stored in Foo/DBIx.pm, the error isn't thrown. If the regex is changed to /\@INC\b/, the error also goes away. Thanks.
From: troy.tausend [...] target
I have just tried DBI v1.32 to check if the correction noted for v1.31 fixed my problem with the 'RootClass'. The changes in the connect method where the 'RootClass' subclassing is handled look good except for the fact that the "no strict 'refs';" needs to be moved before the test for an explicit 'RootClass' attribute. As for the changes in _load_module, I am not sure that the "$missing_ok" is going to work correctly yet. For me with perl 5.8.0, my $@ looks like the following as one line: Can't locate Bogus/Module.pm in @INC (@INC contains: /usr/opt/perl5/lib/5.00503/aix /usr/opt/perl5/lib/5.00503 /usr /opt/perl5/lib/site_perl/5.005/aix /usr/opt/perl5/lib/site_perl/5.005 .) The regex /^\@INC\b/ is anchored at the beginning of the line where as the first occurance in my error string is 33 characters into the string. Unfortuately I don't have access to versions other the 5.6.1 and 5.8.0 with English. Therefore I don't know that dropping the '^' anchor from the regex won't accidently excuse some other error message since I don't know that the '@INC' alone sufficiently qualifies the error. Oh well, that's my 2 1/2 cents on the subject. Thanks for getting the update for my original 'RootClass' problems out and I look forward to a release correcting the "no strict 'refs';" soon. [guest - Mon Nov 18 17:09:05 2002]: Show quoted text
> Given this example: > > --START-- > package Foo::DBIx; > our @ISA = qw(DBI); > > package Foo::DBIx::db; > our @ISA = qw(DBI::db); > > package Foo::DBIx::st; > our @ISA = qw(DBI::st); > > package main; > > use DBI; > > $dbh = DBI->connect( > 'dbi:Oracle:', 'scott', 'tiger', > { RootClass => 'Foo::DBIx' } > ); > ---END--- > > DBI (v1.30) throws back the following error: > > Can't locate Foo/DBIx.pm in @INC (@INC contains: > /home/prod/perl5/lib/5.6.1/aix /home/prod/perl5/lib/5.6.1 > /home/prod/perl5/lib/site_perl/5.6.1/aix > /home/prod/perl5/lib/site_perl/5.6.1 /home/prod/perl5/lib/site_perl > .) at /home/prod/perl5/lib/site_perl/5.6.1/aix/DBI.pm line 776. > ...propagated at > /home/prod/perl5/lib/site_perl/5.6.1/aix/DBI.pm line 780. > > The DBI documentation says that this should be a non-fatal error: > > [...] that using an explicit RootClass attribute will make the DBI > automatically attempt to load a module by that name (and not > complain if such a module can't be found) [...] > > and code in DBI.pm looks like it tries to ignore this type of error: > > sub _load_module { > (my $module = shift) =~ s!::!/!g; > eval { > require $module.'.pm'; > }; > return 1 unless $@; > return 0 if $@ =~ /^\b\@INC\b/; > die; # propagate $@; > } > > But the regex used doesn't match the error thrown back by perl 5.6.1 > (the regex itself may be flawed, since '@' !~ /\w/). > > If Foo::DBIx is stored in Foo/DBIx.pm, the error isn't thrown. > > If the regex is changed to /\@INC\b/, the error also goes away. > > Thanks.
I believe this is resolved now. Please reopen/resubmit if not. Thanks.