In article <[EMAIL PROTECTED]>,
"Rhino" <[EMAIL PROTECTED]> writes:

>> The chief advantage of 'SET', as far as I can tell from the manual, is
> that
>> it lets you control the specific values which can be in a column without
>> having to write application lookups to verify that the value you are
>> supplying is one that is valid for the 'SET' column. Therefore, if you had
>> only 3 business types, sole proprietorship, partnership, and corporation,
>> you could put those 3 values in the set and be sure that those are the
> only
>> 3 values that would ever be allowed in the column. That's fine as far as
> it
>> goes and is a very useful thing.

It would be mildly useful if it were true.  Unfortunately, it isn't.
When you try to insert invalid values, MySQL doesn't complain.
Instead, it silently does a conversion to something equally invalid:

  CREATE TABLE t1 (
    id INT UNSIGNED NOT NULL AUTO_INCREMENT,
    val SET ('foo', 'bar', 'baz') NOT NULL,
    PRIMARY KEY (id)
  );

  INSERT INTO t1 (val) VALUES ('foo');
  INSERT INTO t1 (val) VALUES ('foo,bar');
  INSERT INTO t1 (val) VALUES ('qux');
  INSERT INTO t1 (val) VALUES ('foo,qux');

  SELECT id, val FROM t1;

returns
+----+---------+
| id | val     |
+----+---------+
|  1 | foo     |
|  2 | foo,bar |
|  3 |         |
|  4 | foo     |
+----+---------+


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to