I have a single table that looks similar to the following:

class Equipment(Base):
    type = Column(CHAR(1), primary_key=True)
    sub_type = Column(CHAR(1), primary_key=True)
    code = Column(CHAR(5), primary_key=True)


For historical purposes, I cannot modify this table. I would like to setup 
multi-level inheritance similar to this, however it does not work:

class Equipment(Base):
    type = Column(CHAR(1), primary_key=True)
    sub_type = Column(CHAR(1), primary_key=True)
    code = Column(CHAR(5), primary_key=True)
    __mapper_args__ = {'polymorphic_on': type}


class Vehicle(Equipment):
     __mapper_args__ = {'polymorphic_identity': 'V', 'polymorphic_on': 
sub_type}


class Bus(Vehicle)
     __mapper_args__ = {'polymorphic_identity': 'B'}


class Rail(Vehicle)
     __mapper_args__ = {'polymorphic_identity': 'R'}


I can concatenate the multiple column values into a single discriminator 
column_property but then I do not have an easy way to retrieve all vehicles. 
Any ideas?

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/qNSg1VvOrWwJ.
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.

Reply via email to