When an unsigned integer field is used in mysql for auto-subtraction, if the result is smaller than 0, it will directly overflow and no error is reported.
Normally, a bigint unsigned value is out of range error should be reported. At least my local mysql is like this, but it can be executed normally in online mysql, then the field value is changed to more than 4 billion 4294967295...
It may be caused by mysql configuration problems, but I did not find how to configure it or have no permission to configure it. Therefore, you can only get up and down from the program.
The SQL statement generated by the program is similar to the following:
Update table set field = field-1 where xxx = xxx;
Auto-minus 1. If you want to judge the result, do you have to check the database ??
So I used this method.
Change field = field-1:
Field = convert (field + (-1), signed)
This solves the problem. If the value is negative during subtraction, it will be 0 directly.