title: SqlAlchemy - Filtering by Relationship Attribute
body: <p>I don't have much experience with SQLAlchemy and I have a problem, which I can't solve. I tried searching and I tried a lot of code.
  This is my Class (reduced to the most significant code):</p>
  
  <pre><code>class Patient(Base):
      __tablename__ = 'patients'
      id = Column(Integer, primary_key=True, nullable=False)
      mother_id = Column(Integer, ForeignKey('patients.id'), index=True)
      mother = relationship('Patient', primaryjoin='Patient.id==Patient.mother_id', remote_side='Patient.id', uselist=False)
      phenoscore = Column(Float)
  </code></pre>
  
  <p>and I would like to query all patients, whose mother's phenoscore is (for example) <code>== 10</code></p>
  
  <p>As told, I tried a lot of code, but I don't get it. The logically solution, in my eyes, would be</p>
  
  <pre><code>patients = Patient.query.filter(Patient.mother.phenoscore == 10)
  </code></pre>
  
  <p>because, you can access <code>.mother.phenoscore</code> for each element when outputting but, this code doesn't do it.</p>
  
  <p>Is there a (direct) possibility to filter by an attribute of a relationship (without writing the SQL Statement, or an extra join-statement), I need this kind of filter more than one time.</p>
  
  <p>Even if there is no easy solution, I am happy to get all answers.</p>