I have a form that is inserting data into a mySQL database. The datatype is an integer, and it is a required field - set to NOT NULL
in the database. The number input component on the form for this column has a default value of 0. 0 It is fairly often that the user won't need to change the number input from 0 at all, as 0 is a valid input for this case. I have tried clicking the "reset state" button and it will fix it for a couple days - but then the issue comes back for multiple users.
If the user does not change the number input at all from 0, when the insert query runs, the {{numberInput.value}} evaluates to NULL
, even with the "default value" set to 0. This causes an error, since the database rejects the NULL
, because of the NOT NULL
constraint.
I did find a workaround however, if the user uses the stepper buttons to change the number, and then changes it BACK to 0, then the query sends the value as 0 and there is no problem.
For the time being - I've altered by DB table to use DEFAULT 0
and removed the NOT NULL
constraint - but it would be nice if the "default value" worked correctly with 0 values!