Michael Stassen wrote:

Cal Evans wrote:


or '' (empty string). You can change this behavior by building your own mysql from source with the -DDONT_USE_DEFAULT_FIELDS compile option.
Thanks, I'm off to recompile my development server.


you should be able to define a field as NOT NULL without a default or at the very least, define the default as NULL.


This does not make sense to me. Allowing NULL as the default for a column declared NOT NULL would defeat the purpose of declaring it NOT NULL in the first place.
It makes perfect sense. As a matter of fact, declaring a column as NOT NULL and then providing a default value of anything other than NULL means that you are defeating the constraint and it will almost never be triggered. If I set a field as NOT NULL then that means I want the user/application to put some thought into what is going into it. I do not want a default value.

An example would be credit card number. I set that to NOT NULL in my shopping cart. I do a rudimentary check at the FE and I do a more exhaustive check at the middle-tier to make sure that I have a number and it looks valid. However, the order is invalid if I don't have it so at the database level I make that column NOT NULL. If something goes wrong along the way and the first two checks miss it, this one will catch it.

The way my framework works is that the Insert into the database is built based on the values passed in. If ccNumber does not exist then it is not inserted. If the field is NOT NULL and there is a default value of anything OTHER than null then the database will accept an invalid order.

IMHO, FWIW, etc.
=C=


* Cal Evans * http://www.eicc.com * We take care of your IT, * So you can take care of your business. * * I think inside the sphere.



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



Reply via email to