thanks, specifying the tables instead of the declarative classes solved my problem.
On Mon, Nov 21, 2011 at 4:23 AM, Michael Bayer <mike...@zzzcomputing.com>wrote: > > On Nov 20, 2011, at 10:09 PM, Viktor Nagy wrote: > > > Hi, > > > > I'm building a nice query of polymorphically related tables similar to > the one in the docs > > > > session.query(Employee.name).\ > > outerjoin((engineer, engineer.c.employee_id==Employee.employee_id)).\ > > outerjoin((manager, manager.c.employee_id==Employee.employee_id)).\ > > filter(or_(Engineer.engineer_info=='w', Manager.manager_data=='q')) > > > > > > > > now, my problem is that this includes all the columns of engineer and > manager into the subquery > > The query you picture above wouldn't quite produce the subquery in the > left outer join, so I'd assume thats capital Engineer and Manager you're > stating as targets. The subquery is because you're specifying mapped > classes and not Table objects. In a joined inheritance scenario, > "engineer" here would give you exactly the columns of the "engineer" table > alone; while "Engineer" means "the join of employee to engineer" as a > subquery. > > When you want exact columns and full control over what's rendered, use the > Table objects exclusively. > > The other approach I'd normally suggest is to use with_polymorphic(), > though apparently it's not picking up on a single column in the query() > right now, which is unfortunate. > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to sqlalchemy@googlegroups.com. > To unsubscribe from this group, send email to > sqlalchemy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.