Commits to the database must occur at the end of the endpoint handler functions. This is the only way to ensure that the changes made by an API request in the database have actually been committed to the database.
In addition, race conditions are avoided in this way. These can occur if several API calls that refer to each other take place one after the other. For example, an API call may create objects in the database that a subsequent API call that is supposed to retrieve these objects does not return because the commit of the previous API call has not yet taken place.
The following should be implemented:
[ ] All endpoint handler functions must be adapted in such a way that they commit to the database at the end.
Commits to the database must occur at the end of the endpoint handler functions. This is the only way to ensure that the changes made by an API request in the database have actually been committed to the database.
In addition, race conditions are avoided in this way. These can occur if several API calls that refer to each other take place one after the other. For example, an API call may create objects in the database that a subsequent API call that is supposed to retrieve these objects does not return because the commit of the previous API call has not yet taken place.
The following should be implemented:
get_session
function in thedb.database
module should be modified so that it does not commit (see also https://fastapi.tiangolo.com/tutorial/sql-databases/#create-a-dependency).