jeremyevans/sequel — Issue #408: batch inserts do not return meaningful return values
Author: olek
Created: 2011-12-09 22:59:36+00:00
State: open

As I started to use sequel's functionality to perform batch inserts (bravo for including it!), I stumbled on one annoyance - while either insert_multiple and multi_insert work fine, neither is returning meaningful return value. Former returns back array of hashes, and latter returns nil.

It would help a lot if list of ids for created records could be returned from them.

For insert_multiple fix is trivial, simply replace 'each' with 'map' in the DataSet.insert_multiple method.

multi_insert is not so easy, still struggling with it, but I know that this is possible, at least in Postgres, which will happily accept query like "insert into foo (bar, baz) values (1,2), (3,4) returning id".

I understand that my 'issue' is borderline with 'new feature request', but I am desperate to get it working.
It is frequently the case that 2 or more sets of batch data are inserted, and then couple more batches of data are added that use ids from previous batches.

Many thanks for your time and attention!