I’m not sure if this is a bug or expected behaviour.
If I have a live object proxy and delete a row.
Then if I check it’s len it has 1 fewer row - as expected…
But if I try to iterate over the live object then it still tries to iterates over the deleted row which gives an error…
This behaviour is due to the SearchIterator’s caching behaviour. It doesn’t access the server until you actually request data from the row object, at which point it sees that the data is no longer present. As a general rule, if you’re likely to delete a row from a table that you have an existing SearchIterator for, you should handle the anvil.tables.TableError that may occur:
for row in self.live_table:
try:
print(row['title'])
except anvil.tables.TableError as exc:
pass
len() is not cached, so the number of rows is still reported accurately.
Thanks Shaun noted - I think I would have expected the behaviour if it returned len as being 10 but because in returned len as 9 I got confused… It’s as if it knows something has changed but doesn’t know how to change itself.