title: Dealing with Arrays in Flask-SqlAlchemy and MySQL
body: <p>I have a datamodel where I store a list of values separated by comma (1,2,3,4,5...).</p>
  
  <p>In my code, in order to work with <code>arrays</code> instead of <code>string</code>, I have defined the model like this one:</p>
  
  <pre><code>class MyModel(db.Model):
      pk = db.Column(db.Integer, primary_key=True)
      __fake_array = db.Column(db.String(500), name="fake_array")
  
      @property
      def fake_array(self):
          if not self.__fake_array:
              return
  
          return self.__fake_array.split(',')
  
      @fake_array.setter
      def fake_array(self, value):
          if value:
             self.__fake_array = ",".join(value)
          else:
             self.__fake_array = None
  </code></pre>
  
  <p>This works perfect and from the point of view of my source code <strong><em>"fake_array"</em></strong> is an array, It's only transformed into <code>string</code> when it's stored in database.</p>
  
  <p>The problem appears when I try to filter by that field. Expressions like  this doesn't work:</p>
  
  <pre><code>MyModel.query.filter_by(fake_array="1").all()
  </code></pre>
  
  <p>It seems that I cant filter using the <em><code>SqlAlchemy</code> query model</em>.</p>
  
  <p>What can I do here? Is there any way to filter this kind of fields?  Is there is a better pattern for the <strong><em>"fake_array"</em></strong> problem?</p>
  
  <p>Thanks!</p>