Allow deleting tables before updating #140
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is this
There is a use-case when you want to update a table, but delete all entries in that table beforehand, then update in a single transaction. A use-case is where we collect stats on all processes and docker containers periodically. In this case, process and containers may come and go, and so you would want to delete all the old entries and add back the new ones to the table each time instead of figuring out which processes had gone and which have stayed each time. In order to maintain data consistency, we would like this in a single transaction so every time this data is retrieved it has the latest information.
The issue with the current implementation is that since you must pass the table name as "None" to delete, but then I must also pass the table data, but I can't do that because it's the same table. So my data would have to be this for example
{"PROC_STATS": None, "PROC_STATS": {...actual data...}}
which is invalid because of the duplicate key. The solution here is the pass a list of table names to delete before doing the update, but as part of the same transaction.