Is there a way in MySQL table to assign a default when a value that is not in the enumeration is assigned to that field?
CREATE TABLE `comments` (
`status` enum('approved','moderated','unmoderated') NOT NULL DEFAULT 'unmoderated'
);
Works if status
is not defined at creation, but if you set it to something not in the enumeration or NULL, it is "blanked" (doesn't seem to be NULL). I would expect it to be 'unmoderated' if I set it to NULL, since it can't be null. Not sure if that makes sense. Do I need to sanitize my data before inserting to make sure the value exists in the enumeration first?
UPDATE comments SET status = NULL;
UPDATE comments SET status = 'not_in_there';