Re: [sqlalchemy] mapper on a temporary class

2021-01-26 Thread Kent Bower
Thanks a ton for your responses. Do all the normal columns of an aliased class need to match the ad-hoc select to which I map the alias? > oh if the class doesn't have a mapper, then defintiely, just make ad-hoc subclasses of it and map to those.vastly easier that way. Mapping to a subclass

Re: [sqlalchemy] mapper on a temporary class

2021-01-26 Thread Mike Bayer
On Tue, Jan 26, 2021, at 7:31 PM, Kent Bower wrote: > I should have given these details from the get-go: the use case is a > specialized select() (dynamically built) which would be extremely convenient > to map relationships against for convenience in subquery loading, etc. So, > the class

Re: [sqlalchemy] mapper on a temporary class

2021-01-26 Thread Mike Bayer
On Tue, Jan 26, 2021, at 7:31 PM, Kent Bower wrote: > I should have given these details from the get-go: the use case is a > specialized select() (dynamically built) which would be extremely convenient > to map relationships against for convenience in subquery loading, etc. So, > the class

Re: [sqlalchemy] mapper on a temporary class

2021-01-26 Thread Kent Bower
I should have given these details from the get-go: the use case is a specialized select() (dynamically built) which would be extremely convenient to map relationships against for convenience in subquery loading, etc. So, the class would not already have a mapper. Can I pass non_primary=True

Re: [sqlalchemy] mapper on a temporary class

2021-01-26 Thread Mike Bayer
On Tue, Jan 26, 2021, at 3:16 PM, Kent wrote: > Question: if I add a mapper to a class that is only needed temporarily, does > using the mapper compile it along side my "normal" mappers such that I'll > leak memory when I mean for the class to be garbage collected? > > Put another way, can I

[sqlalchemy] Re: Accessing filtered attributes not working

2021-01-26 Thread Diogo Baeder
Sorry, nevermind, found it! "contains_eager" does the trick. I never used it before, and I thought it was just a more complicated way of doing what "joinedload" already does, but it's clearly not. Thanks anyway! :-) On Tuesday, January 26, 2021 at 5:27:51 PM UTC-3 Diogo Baeder wrote: > Hi

[sqlalchemy] Accessing filtered attributes not working

2021-01-26 Thread Diogo Baeder
Hi guys, I may be misunderstanding how SQLAlchemy works in this regard, but somehow I can't figure out how to do a joined query for ORM objects in a way that I can filter on related children objects and have them available (filtered) as attributes. Take this snippet for example:

[sqlalchemy] mapper on a temporary class

2021-01-26 Thread Kent
Question: if I add a mapper to a class that is only needed temporarily, does using the mapper compile it along side my "normal" mappers such that I'll leak memory when I mean for the class to be garbage collected? Put another way, can I add a mapper to a class that doesn't influence my "main