Hi all,

I noticed a problem with DBIx::Class::ResultSource::resolve_prefetch() a
while back, thought I was doing something daft, hacked round it locally
and forgot all about it - until today.

A co-worker was trying to clean up our apache error logs. During the
process he mentioned the issue I'd forgotten about.

In a nutshell, when calling ->prefetch_columns(..) the call spews out
"Use of uninitialized value in pattern match (m//)" warnings.

I've attached a test that demonstrates this (run against 0.08010), the
output I'm seeing from the test (before my fix) and a patch file
containing my fix.

Hopefully it all makes sense and I haven't done anything insane. The
test-suite still passes.

Chisel
-- 
Chisel Wright
e: [EMAIL PROTECTED]
w: http://www.herlpacker.co.uk/

  Perl6 is marmite.

Attachment: CHISEL.bug.resolve_prefetch.t
Description: Troff document

t/CHISEL.bug.resolve_prefetch......
1..3
ok 1 - track resultset class
ok 2 - DBICTest::Schema::Track->can('cd')
not ok 3 - no warnings

#   Failed test 'no warnings'
#   at /usr/local/share/perl/5.8.8/Test/NoWarnings.pm line 45.
# There were 2 warning(s)
#       Previous test 2 'DBICTest::Schema::Track->can('cd')'
#       Use of uninitialized value in pattern match (m//) at 
/home/chisel/development/open_source/feedback/DBIx-Class-0.08010/lib/DBIx/Class/ResultSource.pm
 line 895.
#  at 
/home/chisel/development/open_source/feedback/DBIx-Class-0.08010/lib/DBIx/Class/ResultSource.pm
 line 895
#       
DBIx::Class::ResultSource::resolve_prefetch('DBIx::Class::ResultSource::Table=HASH(0x89a71fc)',
 'cd', 'undef', 'HASH(0x8bd7ac8)', 'undef', 'undef') called at 
/home/chisel/development/open_source/feedback/DBIx-Class-0.08010/lib/DBIx/Class/ResultSource.pm
 line 876
#       
DBIx::Class::ResultSource::resolve_prefetch('DBIx::Class::ResultSource::Table=HASH(0x89a71fc)',
 'HASH(0x87a29c4)') called at t/CHISEL.bug.resolve_prefetch.t line 28
# 
# ----------
#       Previous test 2 'DBICTest::Schema::Track->can('cd')'
#       Use of uninitialized value in concatenation (.) or string at 
/home/chisel/development/open_source/feedback/DBIx-Class-0.08010/lib/DBIx/Class/ResultSource.pm
 line 876.
#  at 
/home/chisel/development/open_source/feedback/DBIx-Class-0.08010/lib/DBIx/Class/ResultSource.pm
 line 876
#       
DBIx::Class::ResultSource::resolve_prefetch('DBIx::Class::ResultSource::Table=HASH(0x89a71fc)',
 'HASH(0x87a29c4)') called at t/CHISEL.bug.resolve_prefetch.t line 28
# 
# Looks like you failed 1 test of 3.
 Dubious, test returned 1 (wstat 256, 0x100)
 Failed 1/3 subtests 

Test Summary Report
-------------------
t/CHISEL.bug.resolve_prefetch.t (Wstat: 256 Tests: 3 Failed: 1)
  Failed test:  3
  Non-zero exit status: 1
Files=1, Tests=3,  1 wallclock secs ( 0.02 usr  0.00 sys +  0.85 cusr  0.02 
csys =  0.89 CPU)
Result: FAIL
--- ./lib/DBIx/Class/ResultSource.pm.dist	2008-06-30 19:35:59.000000000 +0100
+++ ./lib/DBIx/Class/ResultSource.pm	2008-06-30 19:37:37.000000000 +0100
@@ -866,6 +866,7 @@
   $seen ||= {};
   #$alias ||= $self->name;
   #warn $alias, Dumper $pre;
+  $alias ||= ''; # prevent "use of unitialized value" error
   if( ref $pre eq 'ARRAY' ) {
     return
       map { $self->resolve_prefetch( $_, $alias, $seen, $order, $collapse ) }
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[EMAIL PROTECTED]

Reply via email to