Hello.
On 24.9.2012 18:31, Michael Bayer wrote: > > On Sep 24, 2012, at 12:06 PM, Ladislav Lenart wrote: > >> Hello. >> >> Suppose the following example query >> >> q = session.query(A) >> q = q.options(joinedload_all(A.b, B.c, C.d) >> q = q.otions(joinedload_all(A.client, PersonalClient.person) >> return q >> >> where >> >> A has >> b_id FK to b(id) >> client_id FK to client(id) >> B has >> c_id FK to c(id) >> C has >> d_id FK to d(id) >> Client is a root of joined table inheritance >> PersonalClient is Client's subtype which adds >> person_id FK to person(id) >> Person has personal information (such as name and address). >> >> The above query does not work: personal information is not loaded eagerly >> but on >> each access. How should I rewrite the joinedload options to make it work with >> joined table inheritance? > > you'd need to use 0.8, which has not yet had it's initial beta releases, then > options as follows: > > q.options(joinedload_all(A.client.of_type(PersonalClient), > PersonalClient.person)) That will be awesome because this is exactly what I have tried after a bit of googling :-) Unfortunately I am using SA 0.7 ATM. > for 0.7, you'd need to break this down more manually, and this *should* work: > > q.outerjoin(A.client.of_type(PersonalClient), > PersonalClient.person).options(contains_eager(A.client), > contains_eager(A.client, PersonalClient.person)) > > I'd be curious if either/both of these methods work without issue for you, as > this is a tricky one. I will have to dig through the documentation a bit to understand the use of contains_eager option. I will certainly let you know how it behaves. Thank you very much for such a quick response! BTW I am a complete beginner but SA is very pleasant to use so far. Half of the beauty comes from its clever design and the other half from Your commitment and professional assistance :-) Ladislav Lenart -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.