[Dbix-class] $Schema->populate ignores components with ->insert, etc

John Napiorkowski jjn1056 at yahoo.com
Thu Aug 16 15:47:17 GMT 2007


--- Jess Robinson <castaway at desert-island.me.uk>
wrote:

> 
> 
> 
> On Wed, 15 Aug 2007, John Napiorkowski wrote:
> 
> > Hi,
> >
> > I noticed that when using ->populate in void mode
> that
> > it skips any overrides to ->insert and the like. 
> This
> > is because when I wrote that I simple pass the
> data to
> > ->execute_array in the storage class.
> >
> > I don't see an easy way around this since these
> types
> > of modules are overriding ->insert directly, not
> so
> > other method I can call.
> >
> > For the moment I propose to update the
> documentation,
> > since this is the kind of thing that could sting
> you
> > if you don't understand what's going on.  For the
> long
> > term I think we need to separate the methods that
> > actually modify the storage, something
> > 'prepare_insert' that calls 'insert' and then
> > component authors would override that instead of
> new.
> > Then in the ->populate I could call that to
> perform
> > any needed data manipulation.
> >
> > Or is there an easier way?
> >
> 
> 
> Not to degrade your efforts or anything, but I think
> if we make populate 
> do all the things that create does, it doesn't
> really have a reason for 
> existance. IIRC it was supposed to be a quick method
> for entering multiple 
> straight/known values for testing/setting up a
> database..
> 
> Therefore I think documenting it to not run inserts,
> components and any 
> other fancy add-ons is fine.

I agree that there is little point to ->populate
(other than ease of use) if it's not lean enough for
bulk insertions.  Just that the void/array behavior is
very different for the same function and could cause
confusion.  Part of me thinks ->populate shouldn't
have a wantarray context at all, and that the insert
arrayref return array behavior should only be used
with ->create.  Anyway, I've updated 0.80 trunk with
some doc patchs.  Please someone let me know if I
should be doing this someplace else, I might have
misunderstood the repository re-org. Comments wanted,
please!

> 
> We should also enhance the docs pointing at
> create(), when I looked 
> recently it was quite hard to find, whereas populate
> is rather easier. 
> (Even the synopsis in DBIx::Class pod doesn't use
> it). I added a bunch of 
> POD to the actual method in ::ResultSet, but it
> needs to be more noticable 
> somehow..
> 
> Jess

I added a few examples to the create documentation. 
I'm not sure if that will address the real problem
though.

Thanks for the feedback,
John


       
____________________________________________________________________________________
Need a vacation? Get great deals
to amazing places on Yahoo! Travel.
http://travel.yahoo.com/



More information about the DBIx-Class mailing list