On 7/15/15 2:42 AM, Юрий Пайков wrote:
I have an example here
https://gist.github.com/ojomio/aa5eca3bea03d21e00e8. This code issue
exactly one query and load everything at one time
What I am asking about is
line https://gist.github.com/ojomio/aa5eca3bea03d21e00e8#file-gistfile1-py-L65
If I don not use alias *second_B*and simply write
|
).join(
AWithChildren.bs
).options(
contains_eager(B.as_).
contains_eager(A.children,alias=AWithChildren).
contains_eager(AWithChildren.bs).
joinedload(B.cs)
)
|
Then SQLAlchemy issue another query on *C* table, apparently not
matching expression AWithChildren.bs and B
So my question is - if there are many other tables after *A.children
-*should use alias() for every one and mention them like
|
.joinedload(PreviousTable.relation,alias=SomeTableAlias).
|
?
the use here of .joinedload() on the end of a series of contains_eager()
calls is already very unusual, and I'm somewhat surprised it works
correctly in the first case as this is not a use case that's really
tested. As for the case of second_b not being present, this is not
surprising as AWithChildren.bs refers to "B", which is already present
in the query as the primary entity, for a separate collection of B to be
present it needs to be aliased. the join(AWithChildren.bs) is the same
as join(B, AWithChildren.bs), and you'd never want to say what is
essentially session.query(B).join(Q).join(B) - you need an alias for
each subsequent occurrence of B.
--
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
<mailto:sqlalchemy+unsubscr...@googlegroups.com>.
To post to this group, send email to sqlalchemy@googlegroups.com
<mailto:sqlalchemy@googlegroups.com>.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
--
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.
For more options, visit https://groups.google.com/d/optout.