pesky whitespace
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / ResultSource.pm
index d7f20b4..dfa4c78 100644 (file)
@@ -585,7 +585,7 @@ sub name_unique_constraint {
   my ($self, $cols) = @_;
 
   my $name = $self->name;
-  $name = $$name if ref $name;
+  $name = $$name if (ref $name eq 'SCALAR');
 
   return join '_', $name, @$cols;
 }
@@ -1265,18 +1265,22 @@ sub pk_depends_on {
 # hashref of columns of the related object.
 sub _pk_depends_on {
   my ($self, $relname, $rel_data) = @_;
-  my $cond = $self->relationship_info($relname)->{cond};
 
+  my $relinfo = $self->relationship_info($relname);
+
+  # don't assume things if the relationship direction is specified
+  return $relinfo->{attrs}{is_foreign_key_constraint}
+    if exists ($relinfo->{attrs}{is_foreign_key_constraint});
+
+  my $cond = $relinfo->{cond};
   return 0 unless ref($cond) eq 'HASH';
 
   # map { foreign.foo => 'self.bar' } to { bar => 'foo' }
-
   my $keyhash = { map { my $x = $_; $x =~ s/.*\.//; $x; } reverse %$cond };
 
   # assume anything that references our PK probably is dependent on us
   # rather than vice versa, unless the far side is (a) defined or (b)
   # auto-increment
-
   my $rel_source = $self->related_source($relname);
 
   foreach my $p ($self->primary_columns) {