[Dbix-class] bulk_create branch updated

John Napiorkowski jjn1056 at yahoo.com
Fri May 25 05:35:19 GMT 2007


--- John Napiorkowski <jjn1056 at yahoo.com> wrote:

> 
> --- John Napiorkowski <jjn1056 at yahoo.com> wrote:
> 
> > 
> > --- Jess Robinson <castaway at desert-island.me.uk>
> > wrote:
> > 
> > > 
> > > On Thu, 17 May 2007, John Napiorkowski wrote:
> > > 
> > > > Hey,
> > > >
> > > > I checked in an update to the bulk_create
> branch
> > > that
> > > > basically seems to do the job (calls create in
> > > array
> > > > context, but bulk_insert in void context)
> > although
> > > I'm
> > > > not sure if this is much more efficient.  I
> have
> > > to
> > > > call bulk insert for each nested relationship,
> > for
> > > > example.  Also I run a bunch of nasty maps to
> > > convert
> > > > and merge some data structures.  So I'm hoping
> > to
> > > > gather some feedback.
> > > >
> > > > I also still need to clean up the indenting to
> > > conform
> > > > to coding standards.  I'll do that when we all
> > > think
> > > > the code is doing what we want.
> > > >
> > > 
> > > Cool stuff!
> > > 
> > > However, you neglected to create belongs_to rels
> > > before the main object.. 
> > > I've added a test to 101populate_rs which fails
> > for
> > > you ;)
> > > 
> > > Jess
> 
> Okay, I checked in some nasty hacks to make this
> work.
>  I'll clean/refactor it a bit more later.  I also
> updated the tests a bit, please take a look and let
> me
> know if you think I'm still testing for what we
> need.
> 
> I need to add a few tests to make sure I cover void
> and array context for both automatic PKs and
> specified
> PK's.  Right now I don't cover the case were the
> relationship is a has_many type and we are
> automatically creating relating keys.  I have no
> good
> way to handle this in bulk_insert since
> execute_array
> doesn't seem to have a way to return the inserted
> rows.  Any thoughts or directions of research on
> this
> would be appreciated.  Also someone with good
> knowledge of the way we can determine relationships
> should really look at my code and let me know if I'm
> doing this the hard way.  I can see some ways to
> make
> this more efficient, but not much more.
> 
> --john

Hey,

I updated the tests for this to exercise more
carefully   some of the different ways we hope this
would work.  As of now this test fails when you are
using void context and try to populate a resultset
with related objects and fail to specify the related
key(s).  It populates the primary resultset fine, just
right now silently skips the related object.

Unfortunately this works fine when in array context. 
As I mentioned above I am at a loss to solve this
since I have not yet found a way to get execute array
to return created rows.

If you checkout the branch and run the
101populate_rs.t you can see how this fails at the end
of the tests.
So unless someone has a breakthrough idea we'll have
to live without that function.  I suggest in this case
to switch the behavior to the array context method,
since that does work.  Right now I have some code
refactoring on this but without some feedback or
thoughts I'm not sure where to go with it.

Thanks!

John

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Dbix-class mailing list