On Wednesday, October 10, 2018 at 1:52:24 PM UTC-5, Jeremy Evans wrote:
>
> The simplest solution is just to get the sequence number before inserting:
>
>    def before_create
>     super
>     self.order_number = DB.get{nextval("bs_order_number_seq")}
>   end
>

For posterity, here is the solution I ended up with:

def before_create
  super
  self.number ||= Sequel.function(:nextval, Sequel.function(:
pg_get_serial_sequence, self.class.table_name.to_s, 'order_number')) 
end

This lets me specify an order number if desired, avoids a round trip to the 
database, and doesn't require a pre-determined index name. 

-- 
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.

Reply via email to