On Nov 28, 2009, at 10:25 AM, kindly wrote:

> Is there a way of, with every orm update to add extra conditions to
> the where clause and to check (and rollback if fail) that the row that
> was supposed to be updated actually was.  i.e
> 
> user = session.query(User).get(4)  ## id of 4
> user.name = "fred"  ## a change to user name
> session.add(user)
> session.flush()
> 
> I would want the sql that is issued at this point to be changed, so
> instead of just issuing just
> 
> update user set name = "fred" where id = 4
> 
> I would like to add another condition like
> 
> update user set name = "fred" where id = 4  and current_version = 2

this is provided through the "version_id_col" option on mapper().  see the 
highlight at:

http://www.sqlalchemy.org/docs/05/reference/orm/mapping.html?highlight=version_id_col


--

You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.


Reply via email to