[Bast-commits] r7271 - DBIx-Class/0.08/branches/multicreate_fixes/lib/DBIx/Class

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Sun Aug 9 12:39:30 GMT 2009


Author: ribasushi
Date: 2009-08-09 12:39:29 +0000 (Sun, 09 Aug 2009)
New Revision: 7271

Modified:
   DBIx-Class/0.08/branches/multicreate_fixes/lib/DBIx/Class/ResultSource.pm
Log:
Fix an arcane case with pk==fk tables (use the relationship direction specification if it is available

Modified: DBIx-Class/0.08/branches/multicreate_fixes/lib/DBIx/Class/ResultSource.pm
===================================================================
--- DBIx-Class/0.08/branches/multicreate_fixes/lib/DBIx/Class/ResultSource.pm	2009-08-08 23:19:49 UTC (rev 7270)
+++ DBIx-Class/0.08/branches/multicreate_fixes/lib/DBIx/Class/ResultSource.pm	2009-08-09 12:39:29 UTC (rev 7271)
@@ -1258,18 +1258,22 @@
 # 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) {




More information about the Bast-commits mailing list