I'm using Postgres and Sequel::Model and Model#lock!, I've recently come
across a situation where I need to lock a row/model with a specific lock
type, 'FOR NO KEY UPDATE' instead of 'FOR UPDATE'.
As an example, this is what Sequel::Model currently provides
example = Example.first!
example.lock!
# SELECT * FROM examples WHERE id = ? FOR UPDATE
And what I'd ideally like is something like this:
example = Example.first!
example.no_key_lock!
# SELECT * FROM examples WHERE id = ? FOR NO KEY UPDATE
I'm happy to submit a patch for this (I think it's generally useful :) ),
but I wondered what the best way to implement/put it would be?
I can see two possibilities:
1. Change Sequel::Model#lock! to accept different lock types (like
Sequel::DataSet#lock_style), so something like:
example = Example.first!
example.lock!('FOR NO KEY UPDATE')
2. Add a Postgres-specific plugin for Sequel::Model that provides a
#no_key_lock! method (see above)
#2 is the solution I prefer, what do you think?
Cheers,
Pete
--
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.