Don't drop cache table when removing table references
When invalidating the cache entry for a flowmachine query, before dropping the cache entry we first invalidate any Table references pointing to the cache table:
https://github.com/Flowminder/FlowKit/blob/cac6d07692c635d28d9bc65a63f248db55cef687/flowmachine/flowmachine/core/query.py#L804
I wonder whether we should set drop=False here? Because otherwise, invalidating the cache for the table reference will actually drop the query's cache table, earlier than intended (the cache table should be dropped later - here - in the same transaction as the cache record is deleted).
As things stand, if something went wrong between invalidating the table reference and invalidating the cached query itself, I think it would be possible for a cache record to remain after the cache table has been removed.
I think you're right by the way and we should be setting drop to False here.