From: Jason Mills Date: Fri, 28 Feb 2014 23:47:57 +0000 (-0800) Subject: fixes https://rt.cpan.org/Ticket/Display.html?id=93432 X-Git-Tag: v0.05_r2~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c5f3507b3af8bcd16e6540f98cbcae2983a4db1d;p=dbsrgits%2FDBIx-Class-InflateColumn-Object-Enum.git fixes https://rt.cpan.org/Ticket/Display.html?id=93432 # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # On branch master # Your branch is up-to-date with 'origin/master'. # # Changes to be committed: # modified: dist.ini # modified: lib/DBIx/Class/InflateColumn/Object/Enum.pm # new file: t/lib/TestDB/WithBadDefaultValue.pm # # Untracked files: # .DS_Store # .build/ # lib/.DS_Store # lib/DBIx/.DS_Store # lib/DBIx/Class/.DS_Store # lib/DBIx/Class/InflateColumn/.DS_Store # t/regres/ # --- diff --git a/Changes b/Changes index 1c5f6c8..ba353f5 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,7 @@ Revision history for DBIx-Class-InflateColumn-Object-Enum 0.05 Jan 27th 2014 - Updated dist build to distzilla + - fixed https://rt.cpan.org/Ticket/Display.html?id=93432 TODO: fix issue 74086 TODO: fix issue 80705 0.04 Jan 27th 2009 diff --git a/dist.ini b/dist.ini index 393bd27..48eafb3 100644 --- a/dist.ini +++ b/dist.ini @@ -12,6 +12,9 @@ first_version = 0.04 [MetaYAML] [MakeMaker] [Manifest] +[TestRelease] +[ConfirmRelease] +[UploadToCPAN] [PruneCruft] [PruneFiles] @@ -26,3 +29,4 @@ Object::Enum = 0 [Prereqs / TestRequires] Test::More = 0 DBICx::TestDatabase = 0 + diff --git a/lib/DBIx/Class/InflateColumn/Object/Enum.pm b/lib/DBIx/Class/InflateColumn/Object/Enum.pm index 2d66a78..bbcba64 100644 --- a/lib/DBIx/Class/InflateColumn/Object/Enum.pm +++ b/lib/DBIx/Class/InflateColumn/Object/Enum.pm @@ -95,12 +95,11 @@ sub register_column { my $values = $info->{extra}->{list}; my %values = map {$_=>1} @{$values}; - - if ( defined($info->{default_value}) && !exists $values{$info->{default_value}}) { - push(@{$values},$info->{default_value}); - $values->{$info->{default_value}} = 1; - } - + + push(@{$values},$info->{default_value}) + if defined($info->{default_value}) + && !exists $values{$info->{default_value}}; + $self->inflate_column( $column => { inflate => sub { diff --git a/t/lib/TestDB/WithBadDefaultValue.pm b/t/lib/TestDB/WithBadDefaultValue.pm new file mode 100644 index 0000000..473931d --- /dev/null +++ b/t/lib/TestDB/WithBadDefaultValue.pm @@ -0,0 +1,33 @@ +package TestDB::WithBadDefaultValue; + +use strict; +use warnings; + +use base 'DBIx::Class'; + +__PACKAGE__->load_components(qw/ + InflateColumn::Object::Enum + PK::Auto + Core +/); +__PACKAGE__->table('withbaddefaultvalue'); +__PACKAGE__->add_columns( + id => { + data_type => 'number', + is_auto_increment => 1, + is_nullable => 0 + }, + enum => { + data_type => 'varchar', + is_enum => 1, + is_nullable => 0, + default_value => 'badvalue', + extra => { + list => [qw/red green blue/] + }, + } +); +__PACKAGE__->set_primary_key('id'); + +1; + diff --git a/t/regres/rt_93432.t b/t/regres/rt_93432.t new file mode 100644 index 0000000..cd72fed --- /dev/null +++ b/t/regres/rt_93432.t @@ -0,0 +1,24 @@ +package main; + +use Test::More 'no_plan'; + +BEGIN { + use lib 't/lib'; + use_ok 'DBICx::TestDatabase'; + use_ok 'TestDB'; +} + +my $db = DBICx::TestDatabase->new('TestDB'); + +isa_ok $db, 'TestDB'; + +my $rs = $db->resultset('WithBadDefaultValue') + ->create({id => 1}); + +ok defined($rs) && $rs, 'got a resultset' + or diag "ResultSet: $rs"; + +diag $rs->enum; + +1; # end of test +