is_virtual support
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / ResultSource.pm
index b723517..1734d52 100644 (file)
@@ -71,6 +71,18 @@ and don't actually accomplish anything on their own:
     "_engine" => 'InnoDB',
   });
 
+=cut
+
+sub is_virtual { 0 }
+
+=pod
+
+=head2 is_virtual
+
+Returns true if the resultsource is a virtual result source. This stub
+method returns false by default, see L<DBIx::Class::ResultSource::View>
+for more information.
+
 =head2 add_columns
 
   $table->add_columns(qw/col1 col2 col3/);
@@ -905,6 +917,16 @@ sub resolve_prefetch {
       $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 ];