Errata Chapter 10 (v1.0.1), deleting acronym won't actually throw an error

In Chapter 10 (page 164 in PDF) it says

Set the URL to http://localhost:8080/api/acronyms/1/ and the method to DELETE. Send the request and you’ll get an error back because you can’t delete the acronym while it’s linked in a sibling relationship to a category:

Which isn’t true. There won’t be an error and the acronym will be deleted. Because we set the delete rule to .cascade earlier, as was pointed out correctly in the code explanation of page 162

5. Add a reference between the acronymID property on AcronymCategoryPivot and the id property on Acronym. This sets up the foreign key constraint. .cascade sets a cascade schema reference action when you delete the acronym. This means that the relationship is automatically removed instead of an error being thrown.


Additionally, on page 182 it says to open “CategoryTests.swift and uncomment all the code”. Since the chapter didn’t tell me to use the starter project I obviously don’t have those. Might make sense to either advise the user to start with the starter project, or explain how to get the two Tests.swift files into the project.


One more. In the PDF the introduction to Section IV appears on page 357 in between chapter 21 and chapter 22 instead of before chapter 23 as expected.

5 Likes

You’re right, it doesn’t work even if you try with .restrict or .noAction instead of .cascade

I have this same problem where it lets me delete the acronym with ID 1.

@0xtim Can you please help with this when you get a chance? Thank you - much appreciated! :]

Hi all,

Apologies this is an error in the book. We changed the chapter at late notice to allow the iOS app to delete acronyms easily.

The reason why the delete works is because of the cascade rule for delete actions. This will allow the pivot to be deleted before deleting the acronym. If you don’t specify an onDelete action then the delete will fail.

This has been fixed ready for the next edition!

I have the same result, the acronyms get deleted. And how to fix this? I’m curious

@indrac if you want it to fail then remove the onDelete: .cascade from the migration. That will cause the deletes to fail

I only came across this thread as I was composing a post regarding the same issue.

To avoid others running into issues like this it would be great to see more dynamic updates to eBook content.

@errorfreeit Thank you for the heads up - much appreciated! We will update the book soon. Thanks again! :]

Any idea when the next update is coming out? Have been waiting for this for quite a while.

@0xtim Can you please help with this when you get a chance? Thank you - much appreciated! :]

@swiftlearnerforlife the update to the book will be released this month, so not long!

Awesome Tim. Keep up the amazing work!!!

1 Like