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

Matt Whipple matt at mattwhipple.com
Thu Jul 9 22:02:15 GMT 2009


Paul Makepeace wrote:
> 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.
>>     
HTML::FormFu does this I think (treats empty as undefined).
>
> 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
>   
I think the danced around suggestion is that you remove those fields 
from the query entirely and let the database system handle it implicitly.

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