List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:November 28 1999 2:32pm
Subject:Defaulting ENUM column to ""
View as plain text  
>>>>> "Russ" == Russ Southern <russ@stripped> writes:

Russ> According to the manual:
Russ>   If you insert an invalid value into an ENUM (that is, a string not present
Russ>     in the list of allowed values), the empty string is inserted instead as
Russ>     a special error value. 
Russ>   If an ENUM is declared NULL, NULL is also a legal value for the column, and 
Russ>     the default value is NULL. If an ENUM is declared NOT NULL, the default
Russ>     value is the first element of the list of allowed values. 

Russ> I want to make the empty string ('') the default value.

Russ> Yes, I could add it to the list of valid values, but I want the empty string
Russ> to have index=0.

Russ> I am running servers 3.22.20a and 3.22.25.  One is under my control and the
Russ> other is under my advisability.  It looks like this is not a
Russ> version-specific issue, however.

Russ> Any ideas?

Russ> Russ
Russ> russ@stripped

Hi!

Sorry;  The only way to fix this is to extend the MySQL syntax with
something like:

create table t1 (a enum ('a','b','c') default ERROR);

(One can't use  '' in the above syntax as '' may be a allowed value)

Regards,
Monty

PS: Sorry for the late reply;  I am still trying to catch up with the
    mails that piled up during my vacation.

Thread
Defaulting ENUM column to ""Russ Southern2 Nov
  • Defaulting ENUM column to ""Michael Widenius28 Nov