SQLAlchemy targets mapped entities in a result set by their position 
within the Query object's entities.  It's not possible to have a UNION 
that returns some objects of type A and then some objects of type B in 
the same position, unless those two classes are related through 
polymorphic inheritance with a discriminator.



On Mon Jun 16 10:36:04 2014, Craig Sabbey wrote:
> I'm trying to union the same query for 2 tables with the same
> structure, along with joinedloads for these tables. When I use
> DBSession([TABLE]) for each query in the union, the columns come back
> in different orders. If I specify the columns
> (DBSession([TABLE.COL_A], [TABLE.COL_B], ...) then the joinedloads
> fail with "Query has only expression-based entities".
>
> Here is some pseudo-code to hopefully make it clear what I'm trying to do:
>
>   q0 = DBSession.query(T0).options(joinedload('ref')
>   q1 = DBSession.query(T1).options(joinedload('ref')
>   return q0.union_all(q1).all()
>
> Is there another way to perform this query?
>
> --
> 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
> <mailto:sqlalchemy+unsubscr...@googlegroups.com>.
> To post to this group, send email to sqlalchemy@googlegroups.com
> <mailto:sqlalchemy@googlegroups.com>.
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to