title: SQLAlchemy still able to get object from session after deletion
body: <p>I have an endpoint to delete an object from my database. I delete it with the following code:</p>
  
  <pre><code>my_object = Object.query.get(id)
  db.session.delete(my_object)
  db.session.commit()
  return json.dumps({'success': True}
  </code></pre>
  
  <p>I have an API test to test the endpoint where I create an object and then use the endpoint to delete it. I am trying to assert after the deletion happens it isn't in the database.</p>
  
  <pre><code>my_object = MyObject()
  db.session.add(my_object)
  db.session.commit()
  response = requests.delete('{}/my-object/{}'.format(
      os.environ.get('MY_URL'),
      my_object.id
  ))
  self.assertTrue(response.json()['success']) // this passes
  self.assertEqual(200, response.status_code) // this passes
  result = db.session.query(MyObject).get(my_object.id)
  print(result.id) // prints the id of the job even though it is deleted from the database
  </code></pre>
  
  <p>I think this is related to some SQLAlchemy session caching. I have tried <code>db.session.flush()</code>, <code>db.session.expire_all()</code> to no avail. The object is actually being deleted from the database. So I would expect the query result to be <code>None</code>.</p>
  
  <p>I see this in the docs but haven't full wrapped my head around it. <a href="http://docs.sqlalchemy.org/en/latest/orm/session_basics.html#when-do-i-construct-a-session-when-do-i-commit-it-and-when-do-i-close-it" rel="nofollow noreferrer">when to commit and close a session</a></p>
  
  <p>Thanks for any help.</p>