Hi!
I'm using queries with populate_existing modifier, and found this
problem:
I issue a query with populate_existing and some eagerload chain,
ending with class C.
C is refreshed, and have some foreign key attribute changed correctly.
But relation based on that key, if already loaded, will not lazy load
again, and still points to WRONG (old) instance.
This is test:

    def test_populate_existing_with_eager(self):
        s = create_session()
        addr = s.query(Address).get(1)
        order = s.query(Order).get(1)
        old_user = s.query(User).get(7)
        assert addr.user == old_user #lazy loading user attribute

        #Now change the address
        addresses.update(addresses.c.id == 1).execute(user_id=9)
        new_user = s.query(User).get(9)
        #Refreshing Odrder and Address instances
        order =
s.query(Order).populate_existing().options(eagerload('address')).filter_by(id=1).one()
        #Important! addr.user was already loaded!
        assert addr.user_id == 9# refreshed ok
        assert addr.user == new_user , 'Fail! still == old_user, need
to lazy load it again...    '

Same problem with many_to_many relations, but it's more complex to
solve.


--~--~---------~--~----~------------~-------~--~----~
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