[Dbix-class] '' != NULL for great sadness

Paul Makepeace paulm at paulm.com
Thu Jul 9 22:38:10 GMT 2009


On Thu, Jul 9, 2009 at 5:23 PM, Darren Duncan<darren at darrenduncan.net> wrote:
> fREW Schmidt wrote:
>>
>>    Why do you want them to be NULL? As a general rule, unless you have a
>>    specific requirement for NULL they're best avoided (see discussion
>>    passim). Even when you think you have all the bases covered there's
>>    some weird case where they turn out to be a PITA later...
>>
>> How is that the case?  It seems like an undefined value makes perfect
>> sense to allow users to specify.
>
> Sure it makes sense for users to specify that a value is undefined.
>  However, using a SQL NULL isn't always the best way to record this fact.
>  For one thing, there could be a variety of reasons why a value is undefined
> (for example, "missing" versus "not applicable" versus more specific
> reasons) but a SQL NULL wouldn't let you distinguish between them.  A better
> solution is to avoid the use of SQL NULL and instead represent undefined in
> some other way, such as by having an undefined-because meta-data field. --
> Darren Duncan

Yes indeed.
There is copious discussion online and in learned texts about how and
why NULLs can spoil your day.
http://www.bennadel.com/blog/85-Why-NULL-Values-Should-Not-Be-Used-in-a-Database-Unless-Required.htm

DEFAULT '' is almost always the better way.

P

>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive:
> http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk
>



More information about the DBIx-Class mailing list