List:General Discussion« Previous MessageNext Message »
From:Martijn Tonies Date:January 5 2004 1:44pm
Subject:Re: Enum default values
View as plain text  


> [snip]
> Yes, the DEFAULT doesn't apply. However, shouldn't MySQL
> raise an exception because '' isn't a valid value for this ENUM
> specification?
> [/snip]
>
> >From http://www.mysql.com/doc/en/ENUM.html
>
> The value may also be the empty string ("") or NULL under certain
> circumstances:
>
> If you insert an invalid value into an ENUM (that is, a string not
> present in the list of allowed values), the empty string is inserted
> instead as a special error value. This string can be distinguished from
> a 'normal' empty string by the fact that this string has the numerical
> value 0. More about this later.
> If an ENUM is declared NULL, NULL is also a legal value for the column,
> and the default value is NULL. If an ENUM is declared NOT NULL, the
> default value is the first element of the list of allowed values.

ok, but the table was defined as:
create table property (
property_id int(10) unsigned NOT NULL auto_increment,
name char(30) default NULL,
changeday enum('Sun','Mon','Tue','Wed','Thu','Fri','Sat') not null
default 'Sat',
PRIMARY KEY  (property_id)
);

"changeday" is NOT NULL -> but you still can enter
'' ... Strange and, IMO, a bug. What's the use of
restricting to a set of possible values without enforcing it?

With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com

Thread
Enum default valuesRichard Dyce5 Jan
RE: Enum default valuesJay Blanchard5 Jan
  • Re: Enum default valuesRichard Dyce5 Jan
    • Re[2]: Enum default valuesAleksandar Bradaric5 Jan
      • Re: Re[2]: Enum default valuesRichard Dyce5 Jan
  • Re: Enum default valuesMartijn Tonies5 Jan
RE: Enum default valuesJay Blanchard5 Jan
  • Re: Enum default valuesMartijn Tonies5 Jan
RE: Enum default valuesJay Blanchard5 Jan
  • Re: Enum default valuesMartijn Tonies5 Jan
    • Re: Enum default valuesMichael Stassen5 Jan
  • Re: Enum default valuesMartijn Tonies5 Jan