From: Michael G Schwern <mschwern@cpan.org>
Date: Thu, 6 Nov 2008 12:44:27 +0000 (+0000)
Subject: mk_group_accessor() is sometimes called internally when inflating a column
X-Git-Tag: v0.08240~261
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8c1220a47f7c49b4528617197d3e8d66d2e0b386;p=dbsrgits%2FDBIx-Class.git

mk_group_accessor() is sometimes called internally when inflating a column
and with an array ref field spec, but the accessor and column names are
the same.  Special case that to go through the usual accessor_name_for stuff.
---

diff --git a/lib/DBIx/Class/CDBICompat/AccessorMapping.pm b/lib/DBIx/Class/CDBICompat/AccessorMapping.pm
index c09140f..b7945b0 100644
--- a/lib/DBIx/Class/CDBICompat/AccessorMapping.pm
+++ b/lib/DBIx/Class/CDBICompat/AccessorMapping.pm
@@ -11,7 +11,7 @@ sub mk_group_accessors {
         my($accessor, $col) = ref $col ? @$col : (undef, $col);
 
         my($ro_meth, $wo_meth);
-        if( defined $accessor ) {
+        if( defined $accessor and ($accessor ne $col)) {
             $ro_meth = $wo_meth = $accessor;
         }
         else {
@@ -21,13 +21,14 @@ sub mk_group_accessors {
 
         # warn "class: $class / col: $col / ro: $ro_meth / wo: $wo_meth\n";
         if ($ro_meth eq $wo_meth or # they're the same
-              $wo_meth eq $col)     # or only the accessor is custom
-          {
-              $class->next::method($group => [ $ro_meth => $col ]);
-          } else {
-              $class->mk_group_ro_accessors($group => [ $ro_meth => $col ]);
-              $class->mk_group_wo_accessors($group => [ $wo_meth => $col ]);
-          }
+            $wo_meth eq $col)     # or only the accessor is custom
+        {
+            $class->next::method($group => [ $ro_meth => $col ]);
+        }
+        else {
+            $class->mk_group_ro_accessors($group => [ $ro_meth => $col ]);
+            $class->mk_group_wo_accessors($group => [ $wo_meth => $col ]);
+        }
     }
 }