Hi Michael,
If you have time to take a look, I put up a short gist with some additional
detail:
https://gist.github.com/4505226
We are doing this:
# 'self' is an Article model, which is 1-to-many with Comments, which
are 1-to-1 with Users, which is 1-to-1 with Profile.
# All four tables/models have a PK called 'id', which I think is the
root cause of the problem.
self.comments.options(
subqueryload('user')).options(
subqueryload('user.profile')).all()
which I believe would be better expressed like this:
self.comments.options(
subqueryload_all('user.profile')).all()
When you print the text of the query, the first version is not using AS's
in the select, the second version is.
BUT, both versions still cause the use_labels warning, so I think the issue
is not with the top-level query, but the query/queries being generated to
load User and Profile.
thanks again,
--Bill
On Thu, Jan 10, 2013 at 9:24 AM, Michael Bayer <[email protected]>wrote:
>
> On Jan 10, 2013, at 11:48 AM, Bill Curtis wrote:
>
> > Hi...
> >
> > We are seeing many queries generated via relationship() issue this a
> warning with this advice:
> >
> > "Consider use_labels for select() statements."
> >
> > I'm trying to figure out how to set use_labels, or apply_labels on the
> generated query, but I'm completely stumped.
> >
> > Is it possible to do this, or should I be trying to solve this problem
> in a different way? We are using 0.7.9.
>
> this often has to do with mappings that are to select() constructs
> containing multiple tables. It's an advanced situation and I'd need to
> see how your mappings look.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/sqlalchemy?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.