On Wednesday, November 21, 2018 at 7:41:19 PM UTC-8, Jason wrote:
>
> I am figuring out how to import bulk CSV data where each input row will 
> result in a created record in one table with one or more associated records 
> in another table. I'd like to continue using Dataset#import but the 
> associated records need to reference the primary key of the "parent" 
> records. I think I can use multiple calls to #import but will need the 
> primary keys, which are returned when using the :return option, to populate 
> the foreign key field of the "child" records. Can I rely on the primary 
> keys returned from #import being in the same order as the input rows passed 
> to #import? My plan is to match the returned primary keys with the input 
> CSV rows to then call #import again to insert the associated rows. Do you 
> see any pitfalls or better approaches to this scenario? Thanks!
>

Yes, the return value of the primary key array should correspond to the 
order of records passed to import.  I believe your approach should work, 
but you would definitely want to test that to make sure.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To post to this group, send email to sequel-talk@googlegroups.com.
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to