Skip Menu |

This queue is for tickets about the DBIx-Class-InflateColumn-Object-Enum CPAN distribution.

Report information
The Basics
Id: 114291
Status: new
Priority: 0/
Queue: DBIx-Class-InflateColumn-Object-Enum

People
Owner: Nobody in particular
Requestors: FGA [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Why is a default value required for nullable columns?
I got this exception today: Object::Enum requires a default value when a column is nullable at /home/fgabolde/perl5/perlbrew/perls/dataranger/lib/site_perl/5.18.2/DBIx/Class/InflateColumn/DateTime.pm line 113. (disregard the source file and line number -- looks like an unrelated bug when using multiple inflaters on the same result class) Sure enough I had a NULLable column with no default value: "foobar", { data_type => "enum", is_nullable => 1, is_enum => 1, extra => { list => [qw/foo bar/] } }, I don't get why a default value should be required. The inflater code basically equates unset and is_nullable, as expected: $c->{unset} = $info->{is_nullable} if exists $info->{is_nullable} and $info->{is_nullable}; $c->{default} = $info->{default_value} if exists $info->{default_value}; my $e = Object::Enum->new($c); $e->value($val); All that's needed for NULL values to work is to do this instead: $e->value($val) if defined $val; Then $row->column->value will just return undef, which is exactly what it should do when the column is NULL.