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

Paul Makepeace paulm at paulm.com
Thu Jul 9 21:54:22 GMT 2009


On Thu, Jul 9, 2009 at 4:47 PM, fREW Schmidt<frioux at gmail.com> wrote:
> On Thu, Jul 9, 2009 at 4:34 PM, Chisel Wright <chisel at herlpacker.co.uk>
> wrote:
>>
>> On Thu, Jul 09, 2009 at 10:17:46AM -0500, fREW Schmidt wrote:
>> >    Oh yeah, I saw that for sure.� I was hoping for some kind of setting
>> > that
>> >    I could set that would convert '' to null in fields that aren't
>> > strings.�
>>
>> Erk! Each to their own.
>>
>> Where are these empty strings coming from in the first place? Ideally,
>> and unsurprisingly, I'd much rather have "undef" for "a field value that
>> hasn't been defined".
>>
>> To me, and presumably others, '' (blank) means "we know what it is, it's
>> nothingness".
>>
>> Can't the incoming data be "fixed" instead of kludging your queries?
>
> Well that's what I'm doing.  I'm fixing it.  Iterating over given values and
> changing them from blanks to undefs.  If you know a way to do that with
> javascript (http posts) let me know, but as far as I know it will submit
> blanks for blank fields.

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...

Paul



More information about the DBIx-Class mailing list