fixes https://rt.cpan.org/Ticket/Display.html?id=93432
Jason Mills [Fri, 28 Feb 2014 23:47:57 +0000 (15:47 -0800)]
# 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/
#

Changes
dist.ini
lib/DBIx/Class/InflateColumn/Object/Enum.pm
t/lib/TestDB/WithBadDefaultValue.pm [new file with mode: 0644]
t/regres/rt_93432.t [new file with mode: 0644]

diff --git a/Changes b/Changes
index 1c5f6c8..ba353f5 100644 (file)
--- 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
index 393bd27..48eafb3 100644 (file)
--- 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
+
index 2d66a78..bbcba64 100644 (file)
@@ -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 (file)
index 0000000..473931d
--- /dev/null
@@ -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 (file)
index 0000000..cd72fed
--- /dev/null
@@ -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
+