Files
notifications-api/app
Leo Hemsted 4d418b7f95 set delete(synchronize_session=False) on bulk deletes
When we're bulk updating, make sure we call `synchronize_session=False`,
and make sure that we then commit before we try and access any ORM
objects in the session that might be deleted.

Tutorial time:

when you delete, sqlalchemy needs to work out what to do with objects in
the session. "evaluate", "fetch", or False (do nothing). It wants to
remove items from the session if you're about to delete them, so that
you don't get confused about the state of objects

* evaluate compares the delete query to each item in the session in
  turn. this is the default. if you have lots in the session this could
  be super slow I guess but that's rarely the case for us. This can lead
  to errors if the column names are different to the model names, like
  on our notification and history models.
* fetch runs the delete query as if it's a select, and then checks the
  results of that vs the session. This could be slow.
* False doesn't do anything. This means the session will be stale and
  potentially will contain now-deleted items, until we call `commit` or
  `expire_all` on the session.

https://docs.sqlalchemy.org/en/13/orm/query.html?highlight=query.update#sqlalchemy.orm.query.Query.delete
2020-03-20 17:46:47 +00:00
..
2020-03-16 16:45:34 +00:00
2020-02-24 11:26:16 +00:00
2020-02-18 14:59:46 +00:00
2020-01-24 13:18:37 +00:00
2020-03-19 13:41:14 +00:00
2020-02-14 14:15:41 +00:00
2020-01-24 13:18:37 +00:00
2020-03-16 16:45:34 +00:00