Re: [sqlalchemy] add/update causing InvalidRequest for object with association_proxy lookup

2022-05-16 Thread Mike Bayer
oh an additional clarifying point. if you are seeing that error message happen on a detached object, which seems to go away when you "expunge()" the object sooner, that's because your session is expiring on commit. if your application works with detached objects, you must set expire_on_commit

Re: [sqlalchemy] add/update causing InvalidRequest for object with association_proxy lookup

2022-05-16 Thread Mike Bayer
that error message still describes an object that isn't associated with a Session. If you organize your application to deal with objects only within the scope of a single session, and never once that session has been closed, you won't get that error message. On Mon, May 16, 2022, at 12:07

Re: [sqlalchemy] add/update causing InvalidRequest for object with association_proxy lookup

2022-05-16 Thread Nathan Johnson
Hi Mike Thanks a lot for taking a look and your speedy reply. The reason it was being used in this context is that it's the only way I could get the proxied attribute to resolve after the session had closed, despite the relationship having `lazy='subquery'` specified i.e. eager loading. Witho