checks if the complex conditions are overriden in set_from_related
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / ResultSource.pm
index 9d5f0dc..4f41baa 100644 (file)
@@ -1568,7 +1568,13 @@ sub _resolve_condition {
       $self->throw_exception ('Unable to determine relationship name for condition resolution');
     }
 
-    return $cond->($for, ref $for ? 'me' : $as, $self, $rel, ref $for ? $for : undef);
+    return $cond->({
+      self_alias => ref $for ? $as : $for,
+      foreign_alias => ref $for ? $self->related_source($rel)->resultset->current_source_alias : $as,
+      self_resultsource => $self,
+      foreign_relname => $rel,
+      self_rowobj => ref $for ? $for : undef
+    });
 
   } elsif (ref $cond eq 'HASH') {
     my %ret;
@@ -1671,6 +1677,7 @@ sub _resolve_prefetch {
         "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 =~ /([^\.]+)$/);
@@ -1684,6 +1691,7 @@ sub _resolve_prefetch {
           . 'Use at your own risk.'
         );
       }
+
       #my @col = map { (/^self\.(.+)$/ ? ("${as_prefix}.$1") : ()); }
       #              values %{$rel_info->{cond}};
       $collapse->{".${as_prefix}${pre}"} = [ $rel_source->_pri_cols ];