Hi all,

I have two classes, A and B, and an m2m relationship a_bs. A.bs is mapped 
to B with secondary=a_bs and vice versa. 

My problem is that I need to eagerly populate A.bs and B.as using a single 
SQL query. 

Some notes and constraints:

- I imagine there are some tricks one can do using back population, such as 
eagerly loading all As and A.bs, and just expecting B.as to be populated. 
That might be appropriate if I was writing these queries manually and could 
document such behavior, but all of this happens in a metaprogramming 
context and it's easiest to maintain my invariants if the loading is 
symmetric and explicit.

- I could noload(A.bs) and noload(B.as), and select(a_bs) and manually wire 
everything up. The problem here is that noloaded attributes still track 
writes. For this approach to work, I need to be able to say to the session 
"trust me, this object is already in the collection, don't mess with it". 
Ideally after this process the internal state of the list would be the same 
as if I eagerloaded it normally. 

- I cannot add an explicit AB association class to my model. Speed and 
memory usage is very important here, and spending time creating lots of 
unused objects won't help.

What's the best way to go about this?

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to