The following code is a simple reproduction of the issue.

# create your metadata and session
import sqlalchemy

table = sqlalchemy.Table (
        'test_table', meta,
        sqlalchemy.Column('id', sqlalchemy.Integer, primary_key=True),
        sqlalchemy.Column('foo', sqlalchemy.Integer),
        mysql_engine='InnoDB'
)

class Bar(object):
        pass

mapper =sqlalchemy.orm.mapper(Bar, table)
meta.create_all()


row1 = Bar()
row1.foo = 1
session.begin()
session.save(row1)
session.flush()
s = table.update(table.c.foo == 1, values={table.c.foo: 2})
session.connection(Bar).execute(s)
session.commit()

s = table.select(id == 1, for_update=True)
row2 = session.query(Bar).from_statement(s).all()[0]
print row2.foo




    It also ends up being an issue if you use read committed
transaction isolation level and the update happens in another session
(but that's harder to supply as a super simple script)
    I am using sqlalchemy 0.4.7 and have tried it in 0.4.8 as well. I
have not tried updating to 0.5.x yet, as I have some code that I'm not
ready to migrate yet. Am I doing something wrong, or do I have a bad
expectation? when using for_update, I do not expect to ever get stale
data.
    In fact, since I am using transaction isolation level "read
committed" even without the for_update, I would want to get the
correct, updated value. Since the identity_map is NOT a cache, and the
select statement is always executed, I would expect the updated values
to always be returned.

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

Reply via email to