[Dbix-class] NULL values and DBIx::Class::InflateColumn::DateTime

Will Hawes wdhawes at gmail.com
Sun Aug 3 21:13:11 BST 2008


2008/8/3 Matt S Trout <dbix-class at trout.me.uk>:
> On Sun, Aug 03, 2008 at 01:13:39PM +0100, Will Hawes wrote:
>> The InflateColumn::DateTime helper currently throws "Invalid date
>> format:  " for rows that contain NULL, even if the column info has
>> is_nullable => 1. The docs show that either default_value =>
>> '0000-00-00' or datetime_undef_if_invalid => 1 could be used to work
>> around this, but bypassing inflation completely based on the presence
>> of is_nullable => 1 would be trivial and probably more sensible.
>
> We already bypass inflation of any column that's undef.
>
> get_inflated_column in DBIx::Class::InflateColumn calls _inflate_column
> and the first thing that does is
>
> return $value unless defined $value; # NULL is NULL is NULL
>
> so I'm really not sure how you've contrived to get undef passed to an
> inflator ...

Having reviewed the InflateColumn and InflateColumn::DateTime source
and rewritten my code from scratch, neither am I, as it now works
perfectly.

I wasn't trying to do anything wacky - I just have a single nullable
column defined as "datetime" and am inflating/deflating that. I'd used
InflateColumn as a temporary workaround and unfortunately the original
code never made it into my repository, so I can't even check back to
see what I'd done wrong. Slap.

Clearly one to file under "user error", sorry list.



More information about the DBIx-Class mailing list