Can't set the value of reference field to null

I’m using node.js with a remote MySQL database. When I go to delete the integer in the reference field of one of my tables I get this error:

image

image

Same when trying to remove it by updating it to nothing in my application:
{status: “500”, code: “ER_TRUNCATED_WRONG_VALUE_FOR_FIELD”,…}

I’ve tried setting On Update and On Delete to Set NULL or No Action but nothing has solved it. The only solve I’ve found is using DBeaver and manually setting the value to NULL.

Any thoughts?

Thanks!

I dont think its possible to have a primary key set as NULL

Sorry I should’ve clarified, it’s a foreign key.

What happens when you try setting is as a normal field?

It works perfectly fine with integers.

When an appointment is created the foreign key is null then when a driver is assigned to it the foreign key updates to the driver id. However, the issues arises when I try and remove the driver/driver_id/foreign key from the appointment.

That’s when errors attack.

Maybe try something like this:

2 Likes

You beat me to it!

1 Like

Was initially searching the wrong things, thank you all!

1 Like

Glad you got it sorted out, nothing worse than banging your head against a wall :slight_smile: