On Mon, Jun 11, 2018 at 8:17 AM, Daniel Cardin <d.d.car...@gmail.com> wrote:
>> the fact that you are changing the order of things_check seems to
>> imply you want the order of parent_feature.things to change also....
>> but you're not changing the query.
>
>
> Ugh, woops again. Yes that's exactly what i meant!
>
>> in which case you would use contains_eager()
>
>
> Wow okay, that exactly works.
>
> So I guess i didnt/dont understand understand at all what contains_eager is
> meant to do even after reading the documentation. The join beforehand is
> what generates the sql which ultimately allows contains_eager to load the
> relationship. But how is that different from how it would have worked with a
> normal joinedload (i mean i can see the difference in the generated sql, but
> for me to know that I should have been using contains_eager in the first
> place)?

joinedload:

- generates a JOIN against the target entity, after applying an alias
to it that ensures nothing else in the query will refer towards it
- adds columns, derived from that anonymously aliased table, to the
columns clause of the SELECT which the ORM knows how to link to the
entity collection to be loaded

contains_eager:

- adds columns, derived from the base entity or a user-defined alias
that it is assumed the user has manually placed into the query
already, to the columns clause of the SELECT which the ORM knows how
to link to the entity collection to be loaded


so the rule is, if are not calling query.join(), use joinedload(). if
you *are* calling query.join(), and that's how you want the
relationship()s to be loaded, use contains_eager().







>
> Also, (not that I actually want to in this case) but would it be possible to
> do the same thing with a different relationship loading mechanishm? Like
> suppose this was typically a `selectin` loaded relationship with a default
> order_by on it. Is it possible to have it do the same thing it would have
> done for selectin anyway, order *that* query configurably, and get the same
> end-result?
>
> Anyways, thanks so much. I was banging my head against this for far too
> long!
>
> --
> SQLAlchemy -
> The Python SQL Toolkit and Object Relational Mapper
>
> http://www.sqlalchemy.org/
>
> To post example code, please provide an MCVE: Minimal, Complete, and
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full
> description.
> ---
> 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 https://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
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 https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to