[Dbix-class] Possible problem in DBIx::Class::Manual::Example

Robert Boone robert at rlb3.com
Mon Jun 18 05:50:38 GMT 2007


I was just following the tutorial but testdb.pl was dieing with:
    Can't call method "name" on an undefined value at testdb.pl line 107.

I looked in the database and saw this:

sqlite> select * from track;
1|MyDatabase::Main::Cd=HASH(0x87a7f70)|The Way I Am
2|MyDatabase::Main::Cd=HASH(0x874d888)|Stan
3|MyDatabase::Main::Cd=HASH(0x87a7f88)|Billie Jean
4|MyDatabase::Main::Cd=HASH(0x87a7cf4)|Leave Me Alone
5|MyDatabase::Main::Cd=HASH(0x874d948)|Smooth Criminal
6|MyDatabase::Main::Cd=HASH(0x87a7b2c)|Beat It
7|MyDatabase::Main::Cd=HASH(0x86e6dd8)|Dirty Diana


Should the ResultSet stringifying to the primary key or will something
like this patch be applied?


Index: lib/DBIx/Class/Manual/Example.pod
===================================================================
--- lib/DBIx/Class/Manual/Example.pod   (revision 3509)
+++ lib/DBIx/Class/Manual/Example.pod   (working copy)
@@ -156,7 +156,7 @@
     my $artist = $schema->resultset('Artist')->search({
       name => $albums{$lp}
     });
-    push @cds, [$lp, $artist->first];
+    push @cds, [$lp, $artist->first->id];
   }

   $schema->populate('Cd', [
@@ -180,7 +180,7 @@
     my $cdname = $schema->resultset('Cd')->search({
       title => $tracks{$track},
     });
-    push @tracks, [$cdname->first, $track];
+    push @tracks, [$cdname->first->id, $track];
   }

   $schema->populate('Track',[

Robert



More information about the Dbix-class mailing list