Open colton-flyhomes opened 2 years ago
I think repeating the
if session_persistence == SESSION_PERSISTENCE_FLUSH:
session.flush()
elif session_persistence == SESSION_PERSISTENCE_COMMIT:
session.commit()
block in the use_postgeneration_results
/_after_postgeneration
functions would fix this, but the challenge is being aware of whether the instance was actually created or just fetched via the _get_or_create
feature. I doubt this would be possible at this height of the execution flow, but maybe unconditionally issuing the commit/flush would not be actually harmful? Do post-generation declarations run if the instance was fetched and not created? What is the outcome after a manual flush/commit in that case?
Description
I am using the post_generation method to set a many-to-many relationship. I have
sqlalchemy_session_persistence = 'commit'
, however the many-to-many relationship is not being saved to the DB.To Reproduce
Set
sqlalchemy_session_persistence = 'commit'
Set up many-to-many relationship between two models Create factory for both models Create post_generation method to set many-to-many Callfactory.create()
Model / Factory code
The issue
Once the create method is called, it should save the model objects to the DB along with the many-to-many relationship. However, after running create, there is no DB entry in the association table between the two newly created objects.