All right, thank you very much. Le mardi 9 avril 2013 17:27:38 UTC+2, Michael Bayer a écrit : > > > On Apr 9, 2013, at 11:21 AM, Etienne Rouxel > <rouxel....@gmail.com<javascript:>> > wrote: > > Hello Michael, thank you for your answer. > > It is written in the documentation ( > http://docs.sqlalchemy.org/en/rel_0_8/orm/relationships.html#sqlalchemy.orm.relationship) > > : > >> *innerjoin=False* – >> >> when True, joined eager loads will use an inner join to join against >> related tables instead of an outer join. The purpose of this option is >> generally one of performance, as inner joins generally perform better than >> outer joins. Another reason can be the use of with_lockmode, which does >> not support outer joins. >> >> This flag can be set to True when the relationship references an object >> via many-to-one using local foreign keys that are not nullable, *or when >> the reference is one-to-one or a collection that is guaranteed to have one >> or at least one entry*. >> > So here I am not trying to confuse the query, it is just that there is at > least one entry for RelationB.relation_c. So I thought that SQLAlchemy > would have inferred that the only solution here was to use a LEFT OUTER > JOIN. > > > it only infers that when it follows along a chain of generations from > joinedload(). An outerjoin() applied to the enclosing query is not > detected. > > > > I have the same result if I remove the lazy="joined" and if I use the > query : > > q3 = session.query(RelationA).\ > outerjoin(RelationA.relation_b).\ > options(contains_eager(RelationA.relation_b)).\ > options(joinedload(RelationA.relation_b, RelationB.relation_c)) > > > So, if I understand well, there is nothing wrong with my mapping, right? > The wrong part is just the query and I should fix it as you previously > mentioned, right? > > > yeah, just send along more options that correct its behavior in this case. > > > >
-- 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.