On Aug 31, 2013, at 1:16 AM, gbr <doubl...@directbox.com> wrote:

> Could anyone provide some suggestions on where to look in the SQLA code (or 
> even an example, or some general thoughts) for how to perform a `joinedload` 
> as the ORM does it for Core tables 
> 
> For performance reasons, I prefer using Core for loading data and do the 
> post-processing manually.


this is a really open-ended question, the answer which depends on a. what are 
we starting with, i.e. known tables/columns/etc?  or some kind of alternate 
mapping system?  what are the inputs to the function? and b. what do we get at 
the end?  a result proxy? some kind of object or series of collections ?

a joinedload() is just a JOIN (or LEFT OUTER JOIN).  in Core, you just do this:

        connection.execute(table_a.outerjoin(table_b, table_a.c.id == 
table_b.c.a_id))

so that's a "joinedload".  is that all you need to see ?

> (or actually an already executed query which has unresolved references which 
> I'd like to load in a subsequent query)?

that sounds more like a lazyload....


as far as the actual code in SQLA, it is built to handle an extremely wide 
range of scenarios so it's not that simple to follow for someone unfamiliar 
with the ORM codebase.  It's in sqlalchemy/orm/strategies.py -> JoinedLoader.


Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to