AFAIK there's no built-in way to do this in DM. Besides (probably)
ranking lower in priority, I know there's a conscious intent to avoid
purely RDBMS-oriented/-specific functionality.
The best you can do is directly invoke "LOCK" inside a transaction
block (or whatever RDBMS-specific SQL)
using ::Datamapper.repository.apapter.query("..").
In MySQL, SELECT .. FOR UPDATE is what you're probably looking for,
though I haven't figured out a way to get wiz-bang model creation
along with the invocation -- though you can just retrieve the ID
(only) with your SQL, then Model.first(:id => ..).
Beware though, if you lock rows based on an unindexed field, it's
gonna lock the entire table.
cheers,
--jordan
On Sep 15, 2009, at 3:49 PM, Lucas HĂșngaro wrote:
>
> How can I user a database pessimistic lock with DataMapper? Have tried
> to find it all around without success.
>
> Thanks.
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"DataMapper" 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/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---