Actually, it turns out I'm still getting NULL in the discriminator field of my base classes. In my setup, an AspectDetection inherits from Detection which inherits from Event - the discriminator field of Detection is set properly, but is universally NULL in Event. Any idea why this might be the case?
Thanks! Chris Guin At 10:15 AM 3/28/2008, you wrote: >Thanks! That appears to have done it. > >Chris Guin > >At 05:28 PM 3/27/2008, you wrote: > > > >On Mar 27, 2008, at 3:54 PM, Chris Guin wrote: > > > > > > > > Does anyone know where I could find a working example of multiple > > > levels of inheritance using joined table inheritance? > > > > > > Right now I have the following class hierarchy - an AspectDetection > > > and an RFDetection are subclasses of Detection, which in turn is a > > > subclass of Event. Each of the classes has its own DB table, and an > > > object can be simply an Event or a Detection. I've tried mapping > > > these classes together using the following code: > > > > > > detection_join = > > > detection.outerjoin(aspect_detection).outerjoin(rf_detection) > > > event_join = detection_join.outerjoin(event) > > > >if the ultimate base class is Event, then the "event" table's columns > >must be present in every result set. By outerjoining (where outerjoin > >is a LEFT OUTER JOIN) detection to event, you dont get Event objects > >that are not Detection objects. So event join should be: > > > > event_join=event.outerjoin(detection_join) > > > >Similarly, mapping select_table directly to detection_join for > >detection_mapper does not include any columns from the Event table, so > >those loads would be failing pretty badly. So for that mapper, > >assuming you want all subclasses in one big query, youd want to set > >select_table to: > > > > > >event > >.outerjoin > >(detection).outerjoin(aspect_detection).outerjoin(rf_detection) > > > >the good news is, 0.4.5 will deprecate select_table and you'll just be > >able to say "with_polymorphic='*'" on all your mappers where you want > >a join of all subtables constructed by default - it will do all this > >work for you. > > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---