Two linked tables with publically shared views can cause bugs caused by prefetch caching fields
The specific bug
- On develop
- Create two linked tables
- Publically share both of them (share view -> turn it on)
- Edit the link row field in one and just turn off the 'create related field in other table'
- See the error in the network log/backend logs
What causes this
Deep down in the public view code, before we delete a field we run the following code:
field.table.view_set.filter(public=True).prefetch_related("table__field_set")
- This code only runs when the public view is turned on. The field here is the related field being deleted in step 4 by unchecking the check box.
- You can see it in
baserow.contrib.database.ws.public.fields.signals._get_views_where_field_visible_and_hidden_fields_in_view
- When this code above runs, it actually populates the prefetch cache for
field.table.field_set
- So if you then delete a field (like we are) this prefetched cache on
field.table.field_set
can then cause logical errors later in the process as it thinks that deleted field still exists
The fix in this MR
By simply changing how we fetch these views, we can prevent this odd prefetch cache being populated on field.table.view_set
.