From: Jason Mills Date: Sat, 1 Mar 2014 00:35:03 +0000 (-0800) Subject: fixes https://rt.cpan.org/Ticket/Display.html?id=74086 X-Git-Tag: v0.05_r2~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5cc8e22df33aea52a88f356e596075df10d687e9;p=dbsrgits%2FDBIx-Class-InflateColumn-Object-Enum.git fixes https://rt.cpan.org/Ticket/Display.html?id=74086 --- diff --git a/lib/DBIx/Class/InflateColumn/Object/Enum.pm b/lib/DBIx/Class/InflateColumn/Object/Enum.pm index bbcba64..b171da5 100644 --- a/lib/DBIx/Class/InflateColumn/Object/Enum.pm +++ b/lib/DBIx/Class/InflateColumn/Object/Enum.pm @@ -105,7 +105,7 @@ sub register_column { inflate => sub { my $val = shift; my $e = Object::Enum->new({values=>$values}); - $e->value($val) if $val and exists $values{$val}; + $e->value($val); return $e; }, deflate => sub { diff --git a/t/regres/rt_74086.t b/t/regres/rt_74086.t new file mode 100644 index 0000000..27646c0 --- /dev/null +++ b/t/regres/rt_74086.t @@ -0,0 +1,28 @@ +use Test::More 'no_plan'; + +BEGIN { + use lib 't/lib'; + use_ok 'DBICx::TestDatabase'; + use_ok 'TestDB'; + use_ok 'Try::Tiny'; +} + +my $db = DBICx::TestDatabase->new('TestDB'); + +isa_ok $db, 'TestDB'; + +my $rs = $db->resultset('VarcharEnumNoneNullable') + ->create({id => 1, enum => 'red'}); + +ok defined($rs) && $rs, 'got a resultset' + or diag "ResultSet: $rs"; + +try { + $rs->enum('pink'); + $rs->enum; # trigger inflator +} catch { + ok 1, "Throws an exception: $_" +} finally { + ok 0, 'Does not throw an exception' unless @_; +} +