Юрий Пайков <[email protected]> wrote:

> When I do a query like this
> 
> result = session.query(A).\
> join(A.bs).\
> join(B.cs).\
> filter_by(C.somedata.in_([4455, 4466])).\
> options(contains_eager(A.bs).contains_eager(B.cs)).one()
> 
> and list related C objects
> 
> for b in result.bs:
>    b.cs
> 
> I get all related to B C objects instead of only those with 4455, 4466 values 
> - even though I filtered the output of the statement.


turn on echo=True that will show what SQL is being emitted.      That one() 
might be adding a LIMIT to the query that you don’t want, and the 
contains_eager() might be failing to connect to the collections, and thus they 
are lazy loaded after the fact.





> 
> So eager loading when used with contains_eager() - as I understand - 
> shouldn't load other related objects apart from those which are selected by 
> statement. Still I get Cs with values other that 4455, 4466(i.e. all the 
> collection) :( Could any suggest from where come other Cs? Thanks in advance
> 
> 
> -- 
> 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.

-- 
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