Re: [sqlalchemy] Mimik joinedload for core tables/queries

2013-09-11 Thread gbr
`select_entity_from` finally did the trick. I did qry = session.query(child_query).select_entity_from(parent_query).join(child_query, child_query.c.parent_id==parent_query.c.id) Thanks a lot for your help! On Wednesday, September 4, 2013 2:19:32 PM UTC+10, Michael Bayer wrote: On Sep 3,

Re: [sqlalchemy] Mimik joinedload for core tables/queries

2013-09-11 Thread gbr
I've still got a question... # This is creating an identity map (parent id - children list), but how do we # know the `parent.id` at this point? The query hasn't been issued yet... collections = dict((k, list(v)) for k, v in groupby( child_q,

Re: [sqlalchemy] Mimik joinedload for core tables/queries

2013-09-11 Thread gbr
Never mind. I think I know how this works now. I didn't realise that `child_q` gets executed as soon as it's iterated (despite your comment). Also, the `child.parent_id` is used as key to fill the dict... On Thursday, September 12, 2013 2:54:47 PM UTC+10, gbr wrote: I've still got a

Re: [sqlalchemy] Mimik joinedload for core tables/queries

2013-09-03 Thread gbr
Thanks. That's quite an interesting piece of code. There's a bit of magic happening in this code and it's not quite compatible for my use case (use of queries instead of tables, no ORM mapping), so allow me to ask some questions. I've annotated the code, so perhaps you can correct any of my

Re: [sqlalchemy] Mimik joinedload for core tables/queries

2013-09-03 Thread Michael Bayer
On Sep 3, 2013, at 11:03 PM, gbr doubl...@directbox.com wrote: Thanks. That's quite an interesting piece of code. There's a bit of magic happening in this code and it's not quite compatible for my use case (use of queries instead of tables, no ORM mapping), so allow me to ask some

Re: [sqlalchemy] Mimik joinedload for core tables/queries

2013-09-02 Thread Michael Bayer
On Aug 31, 2013, at 7:33 PM, gbr doubl...@directbox.com wrote: On Sunday, September 1, 2013 8:19:24 AM UTC+10, Michael Bayer wrote: Let me add a bit of information. I assumed the behaviour would be the same in ORM (actually, when looking at the docs again I saw it's actually called

Re: [sqlalchemy] Mimik joinedload for core tables/queries

2013-08-31 Thread gbr
On Sunday, September 1, 2013 8:19:24 AM UTC+10, Michael Bayer wrote: On Aug 31, 2013, at 1:16 AM, gbr doub...@directbox.com javascript: 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

[sqlalchemy] Mimik joinedload for core tables/queries

2013-08-30 Thread gbr
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 (or actually an already executed query which has unresolved references which I'd like to load in a