Re: [sqlalchemy] Re: Should load_only work with hybrid properties?

2019-06-04 Thread Gmoney
I think I get the idea. That's why the properties with hybrid_property.expression defined are able to work as SQL SELECT fields in the cases where a tuple is returned rather than an ORM model... because you don't have to have a place in _dict__ to put it, it just goes into the tuple. My main

Re: [sqlalchemy] Re: Should load_only work with hybrid properties?

2019-06-03 Thread Mike Bayer
I think the thing you need to understand about the "hybrid" is that it isn't "loaded" with the object, that is, it has no place in __dict__ to be stored. The function that you create is invoked every time you access it on your object or class. If you have an object instance of Task, as you've

Re: [sqlalchemy] Re: Should load_only work with hybrid properties?

2019-06-03 Thread Gmoney
I thought I figured out another clever way, but it's not working working as I thought it might. Thought maybe using ".from_self" I could do the base full automatic ORM Model query to get everything, then do the .from_self to wrap it with an outer query and only return the columns I need.

Re: [sqlalchemy] Re: Should load_only work with hybrid properties?

2019-06-03 Thread Gmoney
I think it's starting to make sense. I did misunderstand exactly when the .expression SQL was used - I had thought even queries for ORM models would use it, but I see it does work as you describe. My goal is to return a subset of fields and make that query building operation be dynamic and

Re: [sqlalchemy] Re: Should load_only work with hybrid properties?

2019-06-03 Thread Mike Bayer
well hybrids don't apply to a load_only operation because they are not included in the query that emits when the ORM SELECTs for an object. that is, @hybrid_property.expression gives you a SQL expression, but that's never included when you say session.query(Task). It's only if you said,

[sqlalchemy] Re: Should load_only work with hybrid properties?

2019-06-03 Thread Gmoney
I should at least clarify that I have @hybrid_test.expression in place for that property and it works when I just do the base 'get me everything' query. On Monday, June 3, 2019 at 2:13:17 PM UTC-4, Gmoney wrote: > > I'm trying to use load_only and was able to get a really basic example to >