title: SQLAlchemy filter on list attribute
body: <p>I have the following model defined with Flask-SQLAlchemy:</p>
  
  <pre class="lang-py prettyprint-override"><code>"""models.py"""
  
  from flask_sqlalchemy import SQLAlchemy
  
  db = SQLAlchemy()
  
  skill_candidate = db.Table(
      'SkillCandidate',
      db.Column('skill_id', db.String, db.ForeignKey('skill.id')),
      db.Column('candidate_id', db.Integer, db.ForeignKey('candidate.id')))
  
  class Candidate(db.Model):
      id = db.Column(db.Integer, primary_key=True)
      skills = db.relationship("Skill", secondary=skill_candidate)
  
  class Skill(db.Model):
      id = db.Column(db.String, primary_key=True)
      name = db.Column(db.String, nullable=False, unique=True)
  </code></pre>
  
  <p>What am trying to achieve is the following :
  I want to return all the candidates who possess skills provided in a list input (even ideally, a list of skill_id)</p>
  
  <p>I tried the following :</p>
  
  <pre class="lang-py prettyprint-override"><code>def get_skilled_candidates(skill_ids):
      return Candidate.query.join(skill_candidate).\
         filter(and_(*[skill_candidate.c.skill_id == skill_id for skill_id in skill_ids])).\
              all()
  
  </code></pre>
  
  <p>The aim was to filter all candidates for every skill and compose it with a and_ statement</p>
  
  <p>It works well if I use a list of 1 item (it returns all candidates that possess the skill) but does not if I add more skills in the input list (even tho I have candidates in base that fit the criteria)</p>