title: flask-sqlalchemy filter using text array
body: <p>I'm trying to filter my flask-sqlalchemy query via strings. My procedure for creating the string results in the following array:</p>
  
  <pre><code>["user.name == 'Sid'", "user.role == 'admin'"]
  </code></pre>
  
  <p>It gets formed with something like this:</p>
  
  <pre><code>for i in myarray:
      filter_string = "%s.%s == '%s'" % (self.model.__tablename__, i[0], i[2])
      or_filters.append(filter_string)
  </code></pre>
  
  <p>Here is how I'm using it:</p>
  
  <pre><code>db = SQLAlchemy(app)
  ...
  class myclass:
    def __init(self, model):
      self.model = model
      self.q = db.session.query(self.model)
  
    def get(self, cfg):
      ...
      # the following line works
      myfilter = [User.name == 'Sid', User.role == 'admin']
      # the following line does not work, but I need it to. How to modify into the line above?
      myfilter = ["user.name == 'Sid'", "user.role == 'admin'"]
      if myfilter is not None:
        self.q = self.apply_filter(myfilter)
  
      items = self.q.all()
      return items
  
    def apply_filter(self, ftr):
      self.q.filter(or_(*ftr))
  </code></pre>