I'm trying to reply myself... maybe I could set *polymorphic_identity=None *at the Employee level, and define the DB field EMPLOYEE.TYPE field as not nullable...
Would that work ? Is there a better way ? Thanks ! Franck On Thu, Mar 10, 2011 at 2:00 PM, Franck <[email protected]> wrote: > Hi, > > I read carefully the documentation at > http://www.sqlalchemy.org/docs/orm/inheritance.html and I'd like to > implement a similar joined table inheritance for my application. > > The following example is provided : > > *mapper(Employee, employees, polymorphic_on=employees.c.type, > polymorphic_identity='employee')* > *mapper(Engineer, engineers, inherits=Employee, > polymorphic_identity='engineer')* > *mapper(Manager, managers, inherits=Employee, > polymorphic_identity='manager')* > * > * > However in my case I don't want to be able to persist some random Employee. > All my employees should be engineers or managers. Ideally some exception > should be thrown if I try to add an Employee object to my session. > > Of course, I'd still like to be able to persist Engineers and Managers with > the right type. > > Is there a way to achieve that ? > > Thanks a lot ! > Franck > > -- 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.
