title: SQLAlchemy: filter many-to-one relationship where the one object has a list containing a specific value
body: <p>I have some tables like this:</p>
  
  <pre><code>class Genre(db.Model):
      id = db.Column(db.Integer, primary_key=True)
      name = db.Column(db.String(128), index=True)
      artist_id = db.Column(db.Integer, db.ForeignKey('artist.id'))
  
  class Song(db.Model):
      id = db.Column(db.Integer, primary_key=True)
      name = db.Column(db.String(128), index=True)
      artist = db.relationship('Artist', uselist=False)
      artist_id = db.Column(db.Integer, db.ForeignKey('artist.id'))
  
  class Artist(db.Model):
      id = db.Column(db.Integer, primary_key=True)
      name = db.Column(db.String(128), index=True)
      genres = db.relationship('Genre')
      songs = db.relationship('Song')
  </code></pre>
  
  <p>So basically, Songs have one Artist. And each Artist can have multiple Genres.</p>
  
  <p>I am trying to get all Songs by any Artist whose list of Genre's contains a Genre by a specific name. I did some researching, and I found something very close:</p>
  
  <pre><code>Song.query.filter(Artist.genres.any(Genre.name.in_([genre_name_im_looking_for])))
  </code></pre>
  
  <p>This will sort of work, but not for all cases. For example, the above statement will also return all Songs with Artists who have the Genre 'indie rock'. How can I specify that I don't want the Genre name to be in a list of values, but to be a specific value? </p>
  
  <pre><code>Song.query.filter(Artist.genres.any(Genre.name='rock'))
  </code></pre>
  
  <p>is also not possible because it is a keyword expression.</p>
  
  <p>Any ideas?</p>