If I do a something like this (using postgres):
rows = [
{name: 'Bob'},
{name: 'Cathy'},
{name: 'Steve'}
]
results = Users.multi_insert(rows, return: :primary_key)
=> [1,2,3]
Can I reliably count on the order of the ids returned being the same as the
rows array that I've inserted? I have a need to insert a large number of
records with big strings as references that I'm changing to integers. But
I need to have an in-memory map along the lines of
{
"Bob" => 1,
"Cathy" => 2,
"Steve" => 3
}
# I'm thinking build it something like this:
dictionary = {}
rows.each_with_index do |row, index|
dictionary[row[:name]] = results[index]
end
which I can build from the results if they are reliably in the same order.
This is may be more of a postgres question but I'm hoping someone maybe has
done this!
Thanks,
Jason
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.