naktinis wrote:
> I tried calling .subquery() method on each union subquery like this:
> q1 = Thing.query().filter(...).order_by(Thing.a.desc()).limit
> (1).subquery()
> q2 = Thing.query().filter(...).order_by(Thing.a.asc()).limit
> (1).subquery()
> q = q1.union(q2).order_by(Thing.id)

I know you're not doing that since the alias object returned by subquery()
does not have a union() method.

you'll have to wrap each subquery in a SELECT like this:

q1 = sess.query(C).order_by(C.data).limit(2).subquery().select()
q2 = sess.query(C).order_by(C.data.desc()).limit(2).subquery().select()

print sess.query(C).select_from(union(q1, q2)).order_by(C.data)



--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to