[sqlalchemy] autoflush not working on issued query

2018-02-13 Thread Antoine Lizée
Here is the short example. On the last line, a query is issued to retrieve the object, but the pending DELETE operation is not triggered by the autoflush, resulting in an existing object instead of `None`. Can somebody explain why? us = Country(name="USA") session.add(us) session.commit()

[sqlalchemy] Autoflush doesn't execute when issuing query after object deletion

2018-02-13 Thread Antoine Lizée
Here is a simple example: us = Country(name="USA") session.add(us) session.commit() session.delete(us) assert session.query(Country).get(us.id) is not None # Issues a SELECT query alone session.query(Country).get(us.id + 1) # Issues a SELECT with the flushed DELETE assert

[sqlalchemy] Autoflush doesn't work on a query that is issued after an object deletion

2018-02-13 Thread Antoine Lizée
Here is a simple example: us = Country(name="USA") session.add(us) session.commit() session.delete(us) assert session.query(Country).get(us.id) is not None # Issues a SELECT query alone session.query(Country).get(us.id + 1) # Issues a SELECT with the flushed DELETE assert