I am trying to understand how enums could be used in mysql. If I insert anything to enum field that is out of the enum type -- mysql inserts empty string (with value 0).
Simple misspelling and MySQL inserts empty value, breaks database integrity and makes enums extremely useless.
CHECK constraints could help here but MySQL does not support them (pretty funny for "most popular" database in 2011)
The only way I see is to write the trigger to prevent empty string but it is too much work to write trigger for such a simple case.
Does there is a way to disable "empty string" MySQL behavior for enums?
Thanks
Take a look at sql modes
SET SQL_MODE='TRADITIONAL';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With