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

John Napiorkowski jjn1056 at yahoo.com
Mon Jun 25 23:14:39 GMT 2007


--- Matt S Trout <dbix-class at trout.me.uk> wrote:

> On Mon, Jun 18, 2007 at 09:11:54AM -0700, John
> Napiorkowski wrote:
> > 
> > --- Matt S Trout <dbix-class at trout.me.uk> wrote:
> > 
> > > On Mon, Jun 18, 2007 at 09:35:08AM -0500, Robert
> > > Boone wrote:
> > > > On 6/18/07, Matt S Trout
> <dbix-class at trout.me.uk>
> > > wrote:
> > > > >On Sun, Jun 17, 2007 at 11:50:38PM -0500,
> Robert
> > > Boone wrote:
> > > > >> 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?
> > > > >
> > > > >Neither. DBIC handles deflating related
> objects
> > > automatically; could you
> > > > >tell us what version you've got? (perl
> > > -MDBIx::Class\ 999)
> > > >
> > > > (top-posting fixed, please don't do that)
> > > >
> > > > DBIx-Class-0.08001
> > > > perl 5.8.8
> > > 
> > > Ok, looks like the insert_bulk implementation of
> > > populate introduced a bug.
> > > 
> > > John, could you take a look please?
> > 
> > Looking at it now --john
> 
> Now we're into bugfix territory please ensure you're
> working against trunk.

Hi,

I checked in an update to Schema->populate and
supporting test and also made sure the example stuff
in t/example all ran correctly now.

Basically the issue was very simple, the populate
method in Schema was calling bulk_insert on it's own
and not forwarding to the version of populate in
ResultSet that could deal with this.  I altered the
code so that it did.

To be honest I am not in love with the way this is
working, since the populate in resultset expects a
hashref, and Schema wants arrayrefs.  So you could end
up with mixed up stuff like:

$schema->populate('Artist', [

  [qw/name cds/],
  ["001First Artist", [
	 {title=>"001Title1", year=>2000},
	 {title=>"001Title2", year=>2001},
	 {title=>"001Title3", year=>2002},
  ]],
  ["002Second Artist", []],
  ["003Third Artist", [
	 {title=>"003Title1", year=>2005},
  ]],
]);

Plus I'd rather that the implementation for this
reside in either Schema or Resultset, with one calling
the other.

So this is something I'd like to fix up so that it's
very straightforward.  Should I create a branch for
this, since the changes will not be superficial and it
would be hard to consider it a bugfix?

--John


       
____________________________________________________________________________________
Yahoo! oneSearch: Finally, mobile search 
that gives answers, not web links. 
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC



More information about the Dbix-class mailing list