[sqlalchemy] Re: problem with mapper relationship
the test object you are loading in the update function is local to the update function itself. when the function completes, test falls out of scope and is removed from the session (since it is weakly referenced in the session). a change needs to be made to session whereby dirty objects dont get de-referenced from the session (clean objects have to, thats a long-accepted behavior). since this is the second email in three days about this issue, ticket #388 is added. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: problem with mapper relationship
Michael Bayer ha scritto: the test object you are loading in the update function is local to the update function itself. when the function completes, test falls out of scope and is removed from the session (since it is weakly referenced in the session). a change needs to be made to session whereby dirty objects dont get de-referenced from the session (clean objects have to, thats a long-accepted behavior). since this is the second email in three days about this issue, ticket #388 is added. Thanks. This is a crucial feature for me, since I use this pattern in Twisted (where in a separate thread I create a transaction and a session, passing the connection and session objects to an user define function). 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 sqlalchemy@googlegroups.com 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: problem with mapper relationship
cant reproduce. heres a test case of the above which passes: 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)} ) sess = create_session() test = Test() test.state = TestState() sess.save(test) sess.flush() assert test.state.count == 0 sess.clear() test = sess.get(Test, 1) test.state.count = test.state.count + 1 sess.flush() sess.clear() test = sess.get(Test,1) assert test.state.count == 1 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: Problem with mapper relationship when lazy=False
youre really looking to have an association object pattern here. I thought you might recommend that. My problem last time I tried an association object was that in the following situation: item table keyword table itemkeyword table (and association object) I couldn't get the keywords to eager load when I retrieve items, which is the reason I am trying to kluge this together without an association object. I'll go back and see if I can retrieve items and then do keywords = [ik.keyword for ik in item.itemkeywords] without SQLAlchemy querying the database each time separately from the query that brings back the items. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy -~--~~~~--~~--~--~---
[sqlalchemy] Re: Problem with mapper relationship when lazy=False
the eager load should be able to go through the association object down to the endpoint Keyword objects Thanks -- that does work. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy -~--~~~~--~~--~--~---