On Wednesday, October 10, 2018 at 6:09:31 PM UTC-5, Jeremy Evans wrote: > > 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 >> >> Technically, that's not kosher. Model instance values should be values > and not expressions, and an SQL function is an expression. You sort of get > away with it here since validation is run before the hooks and you probably > aren't running with strict param setting turned on. >
And here I thought I was being clever. Thank you for the guidance. I think the issue can be avoided completely by modifying the > defaults_setter plugin to not cache values if there is no default value. > Try the master branch: > https://github.com/jeremyevans/sequel/commit/8b6f117ff47ff8c28f0b952cc20a07300b9f2ecb > This works great! -- 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.
