On Mar 21, 2012, at 9:49 AM, Kent wrote: > Hoping for advice: I'm using sqlalchemy against a legacy application's > database design, most of which isn't in my control. I have a situation where > single table inheritance should work beautifully but there is one catch: of > the 7 polymorphic sub classes, there is one which is allowed to change into > another. The rest are immutable. As an example, suppose a Employee were > allowed to be promoted to Manager. > > The docs state that the polymorphic_identity is a read only attribute and > that "Behavior is undefined if directly modified." > > I could work around this by mapping 2 polymorphic_identities to one class, > but as far a I can see, this can only be a single scalar value. The docs say > that polymorphic_on may also be of other types besides Column in a future > SQLAlchemy release... I wonder if I can help sqla map either of 2 values to a > class in this way? > > Any advice?
did you try just saying employee.type = 'manager', flushing, then loading a new copy of it ? also polymorphic_on can be any SQL expression in 0.7, like a CASE statement if you wanted. -- 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.