Erik Jacobson wrote:
Sheeri K. Cabral wrote:
My viewpoint:

If I say "don't do that", then don't let me do it. If I told you once, I told you a thousand times....(sorry, channeling my inner Jewish mother)....

Therefore, if I say NOT NULL, I mean "no NULL allowed". No, really. I mean it. Drizzle shouldn't act like a 3-year-old.

Agreed. If you specify NOT NULL without a default, then you are explicitly asking to only accept valid data. Munging it with fake "non data" like an empty string or a zero is something different when you have a default available to you. On the flip side, if you specify a default, then accepting NULL is fine; as it will of course use the default instead.

However, even if the above may seem to be (hopefully) logical behavior, we don't want to make anyone's life harder. So having a default DEFAULT for a given data type may be reasonable if not defined on creation. With the ability to remove the default later if you explicitly want NULL to fail (which would likely be the minority case). Or use some idiom like specifying a self conflicting "NOT NULL DEFAULT NULL" to make a NULL fail on a NOT NULL field. That may be a bit too arcane though.

Actually, a DEFAULT value specified will still not overrule the attempt to insert a NULL value into a non-nullable column.

It is only when you omit the column name in the insert list or explicitly specify the string DEFAULT that the default value will be taken.

Example:
CREATE TABLE T(A INT, B INT NOT NULL DEFAULT 13, C INT NOT NULL DEFAULT 14);

INSERT INTO T(A, B) VALUES(NULL, DEFAULT);

Thanks,
Roy

_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help   : https://help.launchpad.net/ListHelp

Reply via email to