title: Using for loops in sqlalchemy query
body: <p>So i wanna use a for loop in a query and pull results if a record's field is equal to an object's property (in a list of objects) how do i do that? This is my code:</p>
  
  <pre><code>you = session.query(Users).filter_by(id=login_session['userid']).first()
  
  friends = session.query(Friends).filter_by(user_id=login_session['userid']).all()
  
  dashboard = session.query(Markers).filter(Markers.owner == f.friend_id for f in friends).all()
  </code></pre>
  
  <p>but then i get this:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1687, in wsgi_app
      response = self.full_dispatch_request()
    File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1360, in full_dispatch_request
      rv = self.handle_user_exception(e)
    File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1358, in full_dispatch_request
      rv = self.dispatch_request()
    File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1344, in dispatch_request
      return self.view_functions[rule.endpoint](**req.view_args)
    File "/home/pearadox6/travellr/app.py", line 423, in feed
      dashboard = session.query(Markers).filter(Markers.owner == f.friend_id for f in friends).all()
    File "&lt;string&gt;", line 1, in &lt;lambda&gt;
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 51, in generate
      fn(self, *args[1:], **kw)
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 1216, in filter
      criterion = expression._literal_as_text(criterion)
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/expression.py", line 1521, in _literal_as_text
      "SQL expression object or string expected."
  ArgumentError: SQL expression object or string expected.
  </code></pre>
  
  <p>Why?</p>