On Apr 4, 2014, at 5:16 PM, Jonathan Vanasco <jonat...@findmeon.com> wrote:

> I have these 2 tables in the database:
> 
>     class TableA(base):
>         id 
>         field_a
>         field_b
>         items = sa.orm.relationship("TableA_Items", primaryjoin="TableA.id== 
> TableA_Items.table_a_id", backref="table_a")
>         
>     class TableA_Items(base):
>         id 
>         table_a_id 
>         huge_blob_1
>  
> is it possible to set up or query a relationship that will only query the ids 
> from TableA_Items ?  
> 
> Just to be clear, on the ORM, i want to have a collection that is only the 
> IDs from TableA_Items, not the full records themselves.  They're pretty big, 
> and I'd like to avoid them.
> 
> i basically want to be able to use the ORM and have this data
> 
>        session.query( TableA , TableA_Items.id )
> 
> this doesn't look possible based on the docs, but i'm hoping someone here may 
> have run into a similar situation and figured out a workaround.


this is what load_only() was added for:

options(joinedload(TableA.items).load_only('id'))


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to