[Dbix-class] Some thoughts from the group about the resultset->populate method in bulk_create branch

John Napiorkowski jjn1056 at yahoo.com
Tue May 15 18:22:57 GMT 2007


Hi,

I'm hoping to get some thoughts or suggestions about
the best way to approach ->populate for resultsets. 
This is out of the bulk_create branch.

I got this working for the non void context (as Matt
thought it was pretty straightforward).  However the
void context mode of using bulk insert is getting to
me.  I can't see a way for this that is much more
efficient than the array context version, which simple
calls ->create for each row.

My biggest issue here is the fact that if a populated
row is related to populated rows I need to get the
first result in order to correct create the
relationship to the second.  So I need to assume the
first row contains the PKs so I can search on that to
get a resultset I can populate on.  But that's going
to create potentially a lot of statements.  Are we
cool with this?

Some other assumptions I've been making to try and get
the void context version to work:

1) I assume the first item contains all the column key
names.
2) I assume that all the hashes have each of the keys.
 So I changed the test given from:

{name => 'Like I Give a Damn' }

to 

{artistid=>6,  name => 'Like I Give a Damn' }

Otherwise I'm going to have to explicitly create a new
sql statement to handle these special cases which
pretty much negates the value of insert_bulk.

Thoughts and suggestions greatly appreciated!

Semi working version checked in for you all to see. 
This passes all the tests but in order to deal with
the related results issue I am just calling populate
in array context for inner populated rows.

BTW I know I need to fix the way I'm doing indenting
and bracketing, but still working on this.

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