[Bast-commits] r4434 - in DBIx-Class/0.08/trunk: . lib/DBIx/Class t

matthewt at dev.catalyst.perl.org matthewt at dev.catalyst.perl.org
Fri May 30 15:36:16 BST 2008


Author: matthewt
Date: 2008-05-30 15:36:16 +0100 (Fri, 30 May 2008)
New Revision: 4434

Modified:
   DBIx-Class/0.08/trunk/Changes
   DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSource.pm
   DBIx-Class/0.08/trunk/t/03podcoverage.t
   DBIx-Class/0.08/trunk/t/77prefetch.t
Log:
throw exception for multi-has_many prefetch

Modified: DBIx-Class/0.08/trunk/Changes
===================================================================
--- DBIx-Class/0.08/trunk/Changes	2008-05-30 14:32:24 UTC (rev 4433)
+++ DBIx-Class/0.08/trunk/Changes	2008-05-30 14:36:16 UTC (rev 4434)
@@ -1,5 +1,7 @@
 Revision history for DBIx::Class
 
+        - throw a clear exception when user tries multi-has_many prefetch
+        - SQLT parser prefixes index names with ${table}_idx_ to avoid clashes
         - mark ResultSetManager as deprecated and undocument it
         - pod fix (RT #32988)
         - add Test::Exception to test requirements (RT #34256)

Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSource.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSource.pm	2008-05-30 14:32:24 UTC (rev 4433)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSource.pm	2008-05-30 14:36:16 UTC (rev 4434)
@@ -905,6 +905,16 @@
       $self->throw_exception(
         "Can't prefetch has_many ${pre} (join cond too complex)")
         unless ref($rel_info->{cond}) eq 'HASH';
+      my $dots = @{[$as_prefix =~ m/\./g]} + 1; # +1 to match the ".${as_prefix}"
+      if (my ($fail) = grep { @{[$_ =~ m/\./g]} == $dots }
+                         keys %{$collapse}) {
+        my ($last) = ($fail =~ /([^\.]+)$/);
+        $self->throw_exception(
+          "Can't prefetch multiple has_many rels ${last} and ${pre}"
+          .(length($as_prefix) ? "at the same level (${as_prefix})"
+                               : "at top level"
+        ));
+      }
       #my @col = map { (/^self\.(.+)$/ ? ("${as_prefix}.$1") : ()); }
       #              values %{$rel_info->{cond}};
       $collapse->{".${as_prefix}${pre}"} = [ $rel_source->primary_columns ];

Modified: DBIx-Class/0.08/trunk/t/03podcoverage.t
===================================================================
--- DBIx-Class/0.08/trunk/t/03podcoverage.t	2008-05-30 14:32:24 UTC (rev 4433)
+++ DBIx-Class/0.08/trunk/t/03podcoverage.t	2008-05-30 14:36:16 UTC (rev 4434)
@@ -76,6 +76,7 @@
     'DBIx::Class::Relationship::ManyToMany'             => { skip => 1 },
     'DBIx::Class::Relationship::ProxyMethods'           => { skip => 1 },
     'DBIx::Class::ResultSetProxy'                       => { skip => 1 },
+    'DBIx::Class::ResultSetManager'                     => { skip => 1 },
     'DBIx::Class::ResultSourceProxy'                    => { skip => 1 },
     'DBIx::Class::Storage::DBI'                         => { skip => 1 },
     'DBIx::Class::Storage::DBI::DB2'                    => { skip => 1 },

Modified: DBIx-Class/0.08/trunk/t/77prefetch.t
===================================================================
--- DBIx-Class/0.08/trunk/t/77prefetch.t	2008-05-30 14:32:24 UTC (rev 4433)
+++ DBIx-Class/0.08/trunk/t/77prefetch.t	2008-05-30 14:36:16 UTC (rev 4434)
@@ -16,7 +16,7 @@
     eval "use DBD::SQLite";
     plan $@
         ? ( skip_all => 'needs DBD::SQLite for testing' )
-        : ( tests => 58 );
+        : ( tests => 50 );
 }
 
 # figure out if we've got a version of sqlite that is older than 3.2.6, in
@@ -346,7 +346,7 @@
 
 # once the following TODO is complete, remove the 2 stop-gap tests immediately after the TODO block
 # (the TODO block itself contains tests ensuring that the stop-gaps are removed)
-TODO: {
+TODO: if (0) { # broken-ass todo block commented out by mst
     local $TODO = 'Prefetch of multiple has_many rels at the same level (currently must die to protect the clueless git)';
     use DBIx::Class::ResultClass::HashRefInflator;
 




More information about the Bast-commits mailing list