On Thu, Aug 27, 2009 at 00:23, Felipe Ronchi Brigido<[email protected]> wrote:

> I am pretty new to elixir..
> So.. how can i lock some rows while updating them.
>
> I've tried to do:
>
> session.begin()
> upd = MyClass.query().with_lockmode("update").one()
> upd.somenumber += 10
> session.commit()
>
> but not successful. calling to session.begin() raise:
>
> sqlalchemy.exc.InvalidRequestError: A transaction is already begun.
> Use subtransactions=True to allow subtransactions.
>
> and doing only:
>
> upd = MyClass.query().with_lockmode("update").one()
> upd.somenumber += 10
> session.commit()
>
> he doesn't lock.
>
> what am i doing wrong? :S

Sorry, I don't know, I've never used lockmode (I don't even know what
it does exactly). But since the problem is not Elixir-specific, you'll
have a (much) better chance to get an answer by asking the SQLAlchemy
list.

It could be a bug in SQLAlchemy though, because it seems like there
are only tests for with_lockmode("read") in SQLAlchemy's test suite,
so there is an non negligible chance that with_lockmode('update') is
not functioning properly.

-- 
Gaƫtan de Menten
http://openhex.org

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SQLElixir" 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/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to