On Wednesday, July 13, 2016 at 4:01:08 PM UTC+1, Jonathan Underwood wrote: > > > > On Wednesday, July 13, 2016 at 2:35:06 PM UTC+1, Антонио Антуан wrote: >> >> `cteq_alias.union_all(...` >> >> Also, you do not need to create cteq_alias, you can use cteq, like in >> your query, but you have to replace cteq_alias.c.id with cteq.c.id >> >> > Thanks - you're right. That's weird though, as it contradicts the > documentation. Anyway, I've found it all works as expected, simply by not > bothering to create the aliases: > > cteq = session.query(Obj).filter(Obj.parent_id == a.id).cte(recursive=True, > name='cteq_n') > r = cteq.union_all( > session.query(Obj).filter(Obj.parent_id == cteq.c.id) > ) > > objs = session.query(Obj).select_from(r).all() > > > seems to do the job. I've actually ran the example given in the docs > (Query API section), and that fails in the same way I reported in my > original mail too. >
Small addenda: the select_from there should be a select_entity_from. -- 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 https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.