Michael Bayer ha scritto:
> cant reproduce. heres a test case of the above which passes:
>
Sorry: my actual code is a bit different.
from sqlalchemy import *
meta = BoundMetaData('sqlite://', echo=True)
tests = Table('tests',meta,
Column('id', Integer, primary_key=True),
Column('foo', String(30))
)
tests_state = Table('tests_state',meta,
Column('id', Integer, ForeignKey('tests.id'), primary_key=True),
Column('count', Integer, default=0)
)
meta.create_all()
class TestState(object):
pass
class Test(object):
pass
testStateMapper = mapper(TestState, tests_state)
testMapper = mapper(
Test, tests,
properties={'state': relation(TestState, uselist=False)}
)
def update(sess):
test = sess.get(Test, 1)
test.state.count = test.state.count + 1
assert test.state.count == 1
sess = create_session()
test = Test()
test.state = TestState()
sess.save(test)
sess.flush()
sess = create_session()
update(sess)
sess.flush()
sess = create_session()
test = sess.get(Test, 1)
assert test.state.count == 1
This seems very strange to me.
If I call sess.flush inside the update function, all works well.
Thanks and regards Manlio Perillo
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---