On Dec 12, 10:19 am, Olek Poplavsky <[email protected]> wrote:
> Greetings
>
> I am new to Sequel and one feature that brings me to it is batch
> imports - they are simply absent in other ruby ORM, so I ended up hand
> crafting very long SQL strings and executing them, and that made me
> grouchy over time :)
>
> I really like Sequel batch importing feature, namely multi_insert
> method (in addition to it being great simple ruby DSL for SQL).
>
> Nevertheless, I find that its return value (nil) is not right.
> It would be much more helpful if it would return array of primary keys
> of rows just inserted.

I asked Olek to post here as I'm not sure if this feature is desired.
While it's fairly easy to implement on PostgreSQL, it doesn't appear
possible to implement correctly on MySQL without running each INSERT
query separately.  I haven't looked into Microsoft SQL Server support
yet, but it may be possible to implement it efficiently there with the
OUTPUT clause.  All other adapters use a query per row, so it's simple
to implement there as well.

I don't think it's good to make returning the IDs the default
behavior, since it's probably slower to do so, and I expect in most
cases they aren't needed.  But I'll certainly considering implementing
this as an option if people think it is helpful (maybe
a :return=>:primary_key option).  On PostgreSQL it could use
RETURNING, on MySQL it could change behavior to use a separate query
per row, on MSSQL it could do something similar to either PostgreSQL
or MySQL depending on whether OUTPUT can be used.

Anyone have an opinion about this?

Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to