[sqlalchemy] Re: with_polymorphic

2010-04-02 Thread Kent
After doing more reading, this only relates to multiple class
inheritance, which is useful anytime you want two or more classes to
relate to the same record return from the database, is that an
accurate summary?

I'm trying to get of real-life feel for which situations would
benefit from multiple class inheritance so I can spot them if they
present themselves.

Any input for me or other readers at a general level?



On Apr 1, 8:26 pm, Michael Bayer mike...@zzzcomputing.com wrote:
 On Apr 1, 2010, at 8:22 PM, Kent wrote:

  What is the difference between:

  session.query(Employee).join([Engineer, Manager]).\
     filter(or_(Engineer.engineer_info=='w',
  Manager.manager_data=='q'))

  and

  session.query(Employee).with_polymorphic([Engineer, Manager]).\
     filter(or_(Engineer.engineer_info=='w',
  Manager.manager_data=='q'))

 the join to Engineer is going to create select * from employees join (select 
 * from employees join engineer ...) on ...  not what you want. this is 
 another thing I covered at the tutorial this year.   If OTOH you join to 
 Engineer.__table__ and Manager.__table__, you'll get what you want 
 (with_polymorphic is a convenience feature at this piont and not very 
 flexible).



  ?

  --
  You received this message because you are subscribed to the Google Groups 
  sqlalchemy group.
  To post to this group, send email to sqlalch...@googlegroups.com.
  To unsubscribe from this group, send email to 
  sqlalchemy+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://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 sqlalch...@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.



Re: [sqlalchemy] Re: with_polymorphic

2010-04-02 Thread Michael Bayer
Kent wrote:
 After doing more reading, this only relates to multiple class
 inheritance, which is useful anytime you want two or more classes to
 relate to the same record return from the database, is that an
 accurate summary?

I wouldn't say its accurate.   SQLA doesn't support any pattern of
multiple inheritance as represented in the database, so a single record
would not correspond to two classes at the same time, unless one class is
a direct superclass of the other.

with_polymorphic() does imply that multiple class identities are 
significant for the overall result set, however, in that you are
expressing criterion that references elements from more than one class.


-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@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.