I need to query over a  table mapped to class T, 
I usually use session.query (T), however I am using two cte's              
                                          
part0 =  ... cte('part0')
part1 = ... cte('part1')                                                    
                                                                    part2 = 
... cte('aprt2')                                                            
                                                                allparts = 
union (part1.select(), part2.select())                                      
                                            
session.query (allparts)  .. returns row record but I need it to return 
objects of type T?     

I have tried using   q1 = session.query(T).from_statement (allnodes) 
which appears to convert and create objects of T, However, 
I cannot filter or order_by

I have tried using the sql epxression level:
n = allparts.alias()
 DBSession.query (T).from_statement (select ([n]).where (...).order_by 
(...)).all()
or 
 DBSession.query(T).from_statement(DBSession.query 
(n).filter(...).order_by(...).statement).

but I get NoSuchColumnError: "Could not locate column in row for column 
'T.id'"

Is there a way to let SA know how map the columns of the select expression 
to an object?

Thanks.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/7f27eaff-1f0e-40a9-a225-464414d04041n%40googlegroups.com.

Reply via email to