title: Maximum recursion depth exceeded with Sqlalchemy
body: <p>I wrote this loop to dynamically build a select statement using Sqlalchemy in an attempt to have less DB hits.</p>
  
  <p>I don't understand why I'm getting a Maximum recursion depth exceeded Error when <code>query.all()</code> is called.</p>
  
  <p>When I change the recursion depth max to 2000 this query works fine.</p>
  
  <p>Code:</p>
  
  <pre><code>filter_cond = False
  for asset in assets:
      filter_cond = or_(filter_cond, and_(model.version == asset.get("version"),
                                          model.id == asset.get("id"),
                                          model.account_id == account_id))
  query = session.query(model).filter(filter_cond)
  result_set = query.all()
  </code></pre>