On Thursday, October 29, 2015 at 7:33:47 PM UTC-4, Michael Bayer wrote:
>
> i dont have an immediate answer, though i wonder why you aren't using
> ~Bar.is_x.is(True) for that "IS NOT"...
>
Old habits and styleguide. The `~` ended up being missed on too many
glances and code-reviews.
> why would contains_eager("bar") do anything here if you aren't joining
> out to Bar ?
>
...
> mixing joinedload and contains_eager? youd be using join()....
>
I meant to do an `options(joinedload('bar'))` and mistakingly
got `options(contains_eager('bar'))`. it was from a copy/paste error -
grabbing the wrong line.
On my development code, joinedload or no-`options` nets a 26 item
resultset; but putting in `contains_eager` drops it down to 3 items that
have that property.
The difference is between these 2 forms:
[(f.id, f.bar_id) for f in
session.query(Foo).options(joinedload('bar')).order_by(Foo.id.desc()).offset(0).limit(100).all()]
[(f.id, f.bar_id) for f in
session.query(Foo).options(contains_eager('bar')).order_by(Foo.id.desc()).offset(0).limit(100).all()]
In my actual codebase, something drops the 26 items from `joinedload` to
only contain the 3 that have a `bar` on `contains_eager`.
I'd love to figure out WTF is doing that, because it seems to be some bug
or gotcha. The "fix" is simple -- use `joinedload` like I intended.
eager loading takes what it can find at result processing time but
> doesn't assume anything is there. it looks for the columns it expects.
but if the colums aren't there, shouldn't there be an error like
"`contains_eager` called, but query does not contain any usable columns" ?
--
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.