Re: [sqlalchemy] misc questions about finding `association_proxy` "columns"

2019-09-24 Thread Mike Bayer
the association proxies are in mapper.all_orm_descriptors if you can look in there as far as "loaded" you have to dig into the proxy and the attribute it is proxying (which if you've done things this way can be a chain of proxies), I'd have to read the source to know the exact API to use :) see

[sqlalchemy] misc questions about finding `association_proxy` "columns"

2019-09-24 Thread Jonathan Vanasco
I recently shifted some of a database schema around, and thanks to `association_proxy`, I've almost-eliminated the need to adjust my code (thanks, Mike!). I'm left with a situation on my caching layer that I can't seem to work out. I can't seem to to find out the following information (or othe

Re: [sqlalchemy] Re: Filter m2m (exclude some related records)

2019-09-24 Thread kosta
Simon, thank you a lot for your explanation instead of simple code snippet! I appreciate. I'm working on an app based on the flask framework and each incoming request has own session which automatically removes at the end of the request. On Tuesday, September 24, 2019 at 6:37:45 PM UTC+3, S

Re: [sqlalchemy] Re: Filter m2m (exclude some related records)

2019-09-24 Thread Simon King
Before I answer your question, let me try to explain why your attempt didn't work. SQLAlchemy deliberately ensures that a given session only contains a single instance corresponding to an entity in the database. So for example you can run the following: userid = '9e53da4b-f506-46b1-a3be-c0915

[sqlalchemy] Re: Filter m2m (exclude some related records)

2019-09-24 Thread kosta
I've created SQL query which excludes not active tournaments, but I still have no idea how to get a similar result by ORM where the list of user.member_of keeps only active tournament records... select u.*, t.* from "user" u join playeroftournament pt on pt.user_id = u.id join tournament t on pt.