1. Andrew Martinez
  2. sqlalchemy

Commits

Taavi Burns  committed 95a394e

Adjusts example code so it can be successfully pasted into a REPL.

  • Participants
  • Parent commits de004d8
  • Branches default

Comments (0)

Files changed (1)

File doc/build/orm/inheritance.rst

View file
  • Ignore whitespace
         __tablename__ = 'company'
         id = Column(Integer, primary_key=True)
         name = Column(String(50))
-
         employees = relationship("Employee",
                         backref='company',
                         cascade='all, delete-orphan')
 
-
     class Employee(Base):
         __tablename__ = 'employee'
         id = Column(Integer, primary_key=True)
         company_id = Column(Integer, ForeignKey('company.id'))
         __mapper_args__ = {
             'polymorphic_on':type,
-            'polymorphic_identity':employee',
+            'polymorphic_identity':'employee',
             'with_polymorphic':'*'
         }
 
     class Engineer(Employee):
         __tablename__ = 'engineer'
         id = Column(Integer, ForeignKey('employee.id'), primary_key=True)
+        engineer_info = Column(String(50))
         __mapper_args__ = {'polymorphic_identity':'engineer'}
 
     class Manager(Employee):
         __tablename__ = 'manager'
         id = Column(Integer, ForeignKey('employee.id'), primary_key=True)
+        manager_data = Column(String(50))
         __mapper_args__ = {'polymorphic_identity':'manager'}
 
 When querying from ``Company`` onto the ``Employee`` relationship, the