Database delete in repeat Server Action deletes more records at random

Hi all, weird one here.

I have a basic Server Action that takes an array, repeats through it and if a delete “flag” has been set, should delete that record:

The server action works fine updating and adding new records but when one record is to be deleted it often deletes more than one record (normally two and I can’t see a pattern to how it picks the second record)

This is the array sent from my page action where only record with id:3 is flagged to delete (from the 4 entries):

And this is the return from the Server Action showing id:3 was deleted and the other 3 were updated:

And here is the very simple delete query:

BUT, both id:3 and id:2 were deleted from my table.

I have tried with the condition delete_contact==1 and delete_contact!=1 just in case blanks were causing confusion but the same thing happens.

It is probably an obvious mistake but does anyone have any pointers on what I should be looking for?

Paul.

Can you maybe check your database server log to see if it shows you the raw SQL query that’s being executed?

Or maybe before the database delete, can you do a Set Value currentID = {{ id }} and tick the Output checkbox so we can actually see the ID in the JSON response?

Hi Apple,

Thanks for the tips.

It is very strange but it now seems to be working correctly.

After posting the original question and spending a couple of hours trying to identify the cause (I have 3 similar api with the only real difference being the target tables) I created a build (it is an iOS app) and put it on Testflight for my client to play with.

Then this morning, I added the set value step, deployed to my staging server, tried to get SQL log working (it kept failing saying it couldn’t find the log but I will look at that later) then tried again in the browser and Testflight app on my mobile and I can’t replicate the problem.

Very strange and it bugs me that I don’t know what “fixed” it but now it’s working I will move on with the development and keep an eye on it.

Thanks again for taking the time to help.

OK, identified the missing link!
I started using an application called Sizzy (I already use it for basic website development) and this issue with duplicate deletes, and even duplicate inserts only happens when testing the app/site with Sizzy!!!
Back to chrome or Firefox and the process works as expected.
I can now stop worrying about this and move on.

For everybody else that was curious about Sizzy :wink:

3 Likes