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

Darren Duncan darren at darrenduncan.net
Thu Jul 9 22:23:21 GMT 2009


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



More information about the DBIx-Class mailing list