Hi Diana & Michael Bayer, thanks for your help! So, you both use sqlalchemy 0.8 and I use 0.7.9 and that explains our different SQL queries. Now, with the join_depth=1 parameter the unexplainable SQL queries disappear and there is no more difference between lazy='subquery' and subqueryload(). But unfortunately now there is an other and far more problematic issue, the output of showDatabase is incorrect.
I modify my showDatabase() function like this: def showDatabase(session): house = session.query(House).one() for resident in house.residents: print resident.myChildren and now only one resident have a children (the men), and the one from the woman disappear! How is this possible? Here is my complete script with output: http://pastebin.com/HRqSWxQ0 Am Freitag, 23. November 2012 06:43:33 UTC+1 schrieb Michael Bayer: > > > On Nov 22, 2012, at 11:16 AM, Martin84 wrote: > > Hi Diana & Michael Bayer, > > you both have exactly the same results/sql queries, but unfortunately my > results are different. This is really strange, > here is my complete python script with my output: > http://pastebin.com/CyCs90cW > > > As a side note, that script is slightly different. A "lazy='joined'" is > added to Human.houses. So after your session.close(), then your > query(Woman), you get "human JOIN woman" which is the query(Woman), then it > also has "LEFT OUTER JOIN human_house_table LEFT OUTER JOIN house", which > is your Human.houses lazy="joined". I'd usually not use "lazy" at all in a > joined inheritance mapping, as there are already too many JOINs happening > implicitly for there to be extra joins like this coming in. > > So then, why you don't see the "subquery". In 0.7, you need join_depth=1 > here, because otherwise, the ORM sees Woman->Child as Human->Human, which > is a cycle. join_depth=1 means, "it's OK to join one time in this cycle". > > In 0.8 this was improved so that Woman->Child isn't seen as a cycle, the > subclass identity is taken into account - so join_depth can be removed. > See http://www.sqlalchemy.org/trac/ticket/2481 for a description of this > issue. > > Overall, 0.8 has a lot of improvements to joined inheritance in > conjunction with eagerloading and with_polymorphic. > > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/OUUgp8S57XAJ. 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.