Merge branch 'master' into custom_column_info
Robert Bohne [Fri, 19 Feb 2010 06:48:56 +0000 (07:48 +0100)]
Changes
lib/DBIx/Class/Schema/Loader/Base.pm
lib/DBIx/Class/Schema/Loader/RelBuilder.pm
t/lib/dbixcsl_common_tests.pm

diff --git a/Changes b/Changes
index 1a41b81..128d6f0 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,10 @@
 Revision history for Perl extension DBIx::Class::Schema::Loader
 
+        - fix missing trailing _id stripping for some relationship
+          names (rbuels)
+        - fixed accessor POD bug, was not dereferencing scalar refs
+          before printing (rbuels)
+
 0.05002  2010-02-15 10:17:47
         - support for SQLAnywhere via DBD::SQLAnywhere and ODBC
         - fix picking up quoted tables for SQLite (RT#54538) patch from schwern
index c93fa90..4f57523 100644 (file)
@@ -1545,9 +1545,11 @@ sub _make_pod {
            $self->_pod( $class,
                         join "\n", map {
                             my $s = $attrs->{$_};
-                            $s = !defined $s      ? 'undef'          :
-                                 length($s) == 0  ? '(empty string)' :
-                                                     $s;
+                            $s = !defined $s         ? 'undef'          :
+                                  length($s) == 0     ? '(empty string)' :
+                                  ref($s) eq 'SCALAR' ? $$s              :
+                                                        $s
+                                  ;
 
                             "  $_: $s"
                         } sort keys %$attrs,
index 57c5392..4121f64 100644 (file)
@@ -247,10 +247,16 @@ sub generate_code {
         # col names to distinguish
         if($counters{$remote_moniker} > 1) {
             my $colnames = q{_} . join(q{_}, @$local_cols);
-            $local_relname = $self->_inflect_plural(
-                lc($local_table) . $colnames
-            );
+            my $old_relname = #< TODO: remove me after 0.05003 release
+                $local_relname = lc($local_table) . $colnames;
+            my $stripped_id = $local_relname =~ s/_id$//; #< strip off any trailing _id
+            $local_relname = $self->_inflect_plural( $local_relname );
             $remote_relname .= $colnames if keys %cond > 1;
+
+            # TODO: remove me after 0.05003 release
+            $old_relname = $self->_inflect_plural( $old_relname );
+            warn __PACKAGE__." $VERSION: warning, stripping trailing _id from ${remote_class} relation '$old_relname', renaming to '$local_relname'.  This behavior is new as of 0.05003.\n"
+                if $stripped_id;
         } else {
             $local_relname = $self->_inflect_plural(lc $local_table);
         }
index b209fe8..478cf52 100644 (file)
@@ -173,6 +173,8 @@ sub setup_schema {
 
        $warn_count++ for grep /^Bad table or view/, @loader_warnings;
 
+       $warn_count++ for grep /stripping trailing _id/, @loader_warnings;
+
        my $vendor = $self->{vendor};
        $warn_count++ for grep /${vendor}_\S+ has no primary key/,
            @loader_warnings;