title: How to search using SQLAlchemy in a mutable array
body: <p>I am trying to use a mutable array to store data with SQLAlchemy and Postgres and have written these classes:</p>
  
  <pre><code>class MutableList(Mutable, list):
      def append(self, value):
          list.append(self, value)
          self.changed()
  
      def pop(self, index=0):
          value = list.pop(self, index)
          self.changed()
          return value
  
      @classmethod
      def coerce(cls, key, value):
          if not isinstance(value, MutableList):
              if isinstance(value, list):
                  return MutableList(value)
              return Mutable.coerce(key, value)
          else:
              return value
  
  
  class Lead(db.Model):
      __tablename__ = 'leads'
  
      ...
      starred = db.Column(MutableList.as_mutable(db.ARRAY(db.Integer)))
  </code></pre>
  
  <p>And I can update the starred property, both appending and popping items from it. The question I have is how to search for row that has a particular item inside the array. Here's my query:</p>
  
  <pre><code>leads = Lead.query.order_by(Lead.post_date.desc()).filter(Lead.starred.contains(current_user.id)).all()
  </code></pre>
  
  <p>But that gives me the following error: <code>ARRAY.contains() not implemented for the base ARRAY type; please use the dialect-specific ARRAY type</code></p>
  
  <p>What am I missing here?</p>