checks if the complex conditions are overriden in set_from_related
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / ResultSet.pm
index d826e03..124600b 100644 (file)
@@ -2343,8 +2343,16 @@ sub _merge_with_rscond {
 
     while ( my($col, $value) = each %implied ) {
       my $vref = ref $value;
-      if ($vref eq 'HASH' && keys(%$value) && (keys %$value)[0] eq '=') {
-        $new_data{$col} = $value->{'='};
+      if ($vref eq 'HASH') {
+        if (keys(%$value) && (keys %$value)[0] eq '=') {
+          $new_data{$col} = $value->{'='};
+        }
+        # in a complex condition, set_from_related needs to override
+        # the columns that are involved.
+        elsif (!exists $data->{$col} &&
+               !exists $data->{"$alias.$col"}) {
+          $self->throw_exception("unable to set_from_related via complex condition on column(s): '$col'");
+        }
       }
       elsif( !$vref or $vref eq 'SCALAR' or blessed($value) ) {
         $new_data{$col} = $value;