> On 24 Sep 2015, at 17:38, Jonathan Vanasco <[email protected]> wrote:
>
>
>
> On Thursday, September 24, 2015 at 3:05:56 AM UTC-4, David Allouche wrote:
> That looks like the right approach. There is probably something else in your
> actual code that is causing "it [to] not work".
>
> To get a better understanding of "it did not work", I would look at the
> "str(query)" before and after the stuff with the aliased table.
>
> The _aliased object (returned by `sqlalchemy.orm.alias()` does not have
> addressable columns. touching _aliased.string_id and _aliased.c.string_id
> both raise errors.
>
> The rest of the code works fine in production, I just can't seem to figure
> out how to add this table onto the query under a different name which can be
> queried against. The closest thing I could do was to nest everything into
> subselects -- but the sql is grossly inefficient.
Use sqlalchemy.orm.aliased() instead of .alias(). For example:
bar2 = sqlalchemy.orm.aliased(Bar, name='bar2')
Honestly, by reading the documentation, I am confused about how useful
orm.alias() is.
But orm.aliased() is the thing I use all over the place to do what you want.
--
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.