- changed status to closed
session autoflush is not working
I am working with SQLAlchemy and Flask-SQLAlchemy and when I add an object to the session, the session isn't auto flushed. When I add an object to the session, and autoflush
is set to True
, it supposed to send a INSERT operation in the outgoing transaction, right?
After I started getting this problem I made a clean virtual environment with SQLAlchemy (1.0.15)
and a basic Flask application without Flask-SQLAlchemy. I created an engine and a basic session passing autoflush=True
to sessionmaker
. When I call session.add(instance)
, again, the session isn't flushed automatically. I am unable to get an id
. If I echo to the terminal, no database operation seems to happen.
session.autoflush
is returning True. But I have to call session.flush()
manually in order to get an id
and actually send the INSERT statement.
I am missing something? About how autoflush is supposed to work?
Comments (1)
-
repo owner - Log in to comment
autoflush is described here: http://docs.sqlalchemy.org/en/latest/orm/session_basics.html#flushing
Per the bug reporting guidelines at https://bitbucket.org/zzzeek/sqlalchemy/issues/new, this is a usage question, not a bug. Please continue this discussion on the mailing list at https://groups.google.com/forum/#!forum/sqlalchemy. thanks!