title: SQLAlchemy: Subclassed model db entry gets properties of other subclassed model
body: <p>I'm having an issue with SQLAlchemy in a Flask app where I have two models <code>Instructor</code> and <code>Student</code> that subclass the same model <code>User</code>. When I'm creating a <code>Student</code> object, it's listed in the database under <code>User</code> with properties that should be unique for <code>Instructor</code>. Here are my (simplified) classes:</p>
  
  <pre><code>class User(db.Model):
      __tablename__ = "user"
      discriminator = db.Column("type", db.String(50))  # Student or Instructor
      __mapper_args__ = {"polymorphic_on": discriminator}
      id = db.Column(db.Integer, primary_key=True)
      name = db.Column(db.String(50)) 
  
  class Instructor(User):
      __mapper_args__ = {"polymorphic_identity": "instructor"}
      reputation = db.Column(db.Integer, default=1)
      approved_for_teaching = db.Column(db.Boolean, default=False)
  
  class Student(User):
      __mapper_args__ = {"polymorphic_identity": "student"}
      lessons_taken = db.Column(db.Integer, default=0)
  </code></pre>
  
  <p>I'm creating a <code>Student</code> like this:</p>
  
  <pre><code>new_student = Student(name=user_name)
  db.session.add(new_student)
  db.session.commit()
  </code></pre>
  
  <p>But when inspecting the object in the database, the student gets attributes from the <code>Instructor</code> model, i.e. <code>reputation</code> (value is 1) and <code>approved_for_teaching</code> (value is False). Am I doing something wrong here, or is this expected behaviour? I could understand if the columns would have to be present, since they share the same table (<code>User</code>) in the db, but then I'd expect the values to be null or something. Thanks!</p>