What I’m trying to do:
Hi I am creating a prototype for a small business client. In that I start off with dummy data and then put in real example data later that the client gives me. So I simply go to the Data Tables section in Anvil, go to the table i am replacing records for, and simply highlight and delete the rows I don’t want and populate the rows with real data. The app crashes.
Please see the screenshot that I have demonstrated this problem in. I have used Anvil’s own example News tutorial app to show my point. I am deleting all the records in the Categories table and putting the records back with the same data. Still it happens. This one… Anvil | Build Database-Backed Apps.
What I’ve tried and what’s not working:
Throws an error even when I go back and re-populate the Categories data table I have deleted rows from the table and replaced all the rows with identical data. Not a byte of difference. See screenshot showing error. Thank you.
I have found this happens only with linked tables. I later went back to the Articles table, deleted the entire ‘Category’ column, and then recreated a new linked column with the same name Category. I then went and manually mapped each record to a category name in the Categories table. Bingo! Everything started working again. What is happening behind the scenes?
It would be nice if I could upload a short video where I captured all this. But it won’t let me.
When you link to another row (e.g. from table A link to a row in table B) you will get this error if you delete the row in table B that table A is depending on. That’s normal. You’re trying to work with a row that doesn’t exist anymore.
If you’re going to keep the rows from table A, you really should keep the rows from table B they link to, too. If you’re not going to keep the rows from table A, you should delete them along with the rows from table B. Either way should avoid the error.
I just want to point out this seems true at the IDE level, however there is an internal (not shown in the GUI) row-id column / property for each row that is not replicated when you delete-then-replace a row.
For an example of what I am talking about, export one of your tables as a CSV and open the csv (any way you like) it will show you the first row ID column, which consists of a pair of integers.
This row id information is part of what is stored when columns are linked as @jshaffstall describes above.
Exactly what is stored as the content of a “link”.
Guaranteed unique to each row, for its lifetime.
a. Creating a row creates a new, never-before-seen row id.
b. Deleting a row
permanently removes the row id. It will never be used again in that table.
does NOT update any links to that id. Those are now “dangling” links. It is up to your own actions or code to remove/nullify/update those links, if you deem necessary.