Michael,
I was using SA 0.5.1. Upgrading to 0.5.5 resolved the AttributeError.
I am, however, having one final issue with my query:
>>> users = DBSession.query(Post.id.label('post_id'),
>>> Post.user_id.label('user_id')).union(Discussion.__table__.select().with_only_columns(['post_id',
>>> 'user_id']),
>>> DiscussionComment.__table__.select().with_only_columns(['post_id',
>>> 'user_id']))
>>> print users
SELECT anon_1.post_id AS post_id, anon_1.user_id AS user_id
FROM (SELECT posts.id AS post_id, posts.user_id AS user_id
FROM posts UNION SELECT post_id, user_id
FROM discussions UNION SELECT post_id, user_id
FROM discussion_comments) AS anon_1
As far as I can tell, I don't really need the first "SELECT anon"; so
this seems redundant to me (and may be a performance issues as well?).
Can I get it to output without the aliases like:
SELECT posts.id AS post_id, posts.user_id AS user_id
FROM posts UNION SELECT post_id, user_id
FROM discussions UNION SELECT post_id, user_id
FROM discussion_comments
Thanks again,
Seth
On Sep 8, 2:38 pm, "Michael Bayer" <[email protected]> wrote:
> Seth wrote:
>
> > Thank you Michael,
>
> > What about using this type of thing inside another query?
>
> > I keep getting:
>
> > AttributeError: 'Select' object has no attribute '_nested_statement'
>
> the identifier '_nested_statement' is not part of SQLAlchemy so that's
> something on your end (or perhaps you're using an extremely old version of
> SQLAlchemy, which is never recommended).
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---