How do you think is it good idea to have a before_create hook which will
check if disable_insert_returning is set and assign id using nextval()? Is
it possible to check that?
I'm asking this because the code I'm writing need to be working both on
PostgreSQL (some tables partitioned some not) and Redshift which doesn't
support "returning" syntax.
On Wednesday, October 25, 2017 at 1:40:07 AM UTC+3, Jeremy Evans wrote:
>
> On Tuesday, October 24, 2017 at 3:30:51 PM UTC-7, Troex Nevelin wrote:
>>
>> Hi,
>>
>> I want to make one of my tables partitioned, while I can insert using
>> DB[:events].insert({...}) and fetch the ID using
>> DB[:events].get(Sequel.lit('currval(?)',
>> 'events_id_seq')) most of my code uses Models, is there a solution for
>> this case? Is it possible to enable `disable_insert_returning` only for one
>> model instead of entire DB connection?
>>
>
> Yes:
>
> class Event < Sequel::Model(DB[:events].disable_insert_returning)
> end
>
> Note that you'll probably want to set the primary keys manually before
> inserting if you are disabling insert returning.
>
> 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 [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.