Update to add myself to contributors and to hide Modules from the PAUSE Indexer.
[dbsrgits/DBIx-Class.git] / lib / SQL / Translator / Parser / DBIx / Class.pm
index 6ae4a60..53e36ef 100644 (file)
@@ -1,4 +1,5 @@
-package SQL::Translator::Parser::DBIx::Class;
+package # hide from PAUSE 
+    SQL::Translator::Parser::DBIx::Class;
 
 # AUTHOR: Jess Robinson
 
@@ -72,12 +73,10 @@ sub parse {
         }
         $table->primary_key($source->primary_columns);
 
-
         my @rels = $source->relationships();
         foreach my $rel (@rels)
         {
             my $rel_info = $source->relationship_info($rel);
-            print "Accessor: $rel_info->{attrs}{accessor}\n";
             next if(!exists $rel_info->{attrs}{accessor} ||
                     $rel_info->{attrs}{accessor} eq 'multi');
             # Going by the accessor type isn't such a good idea (yes, I know
@@ -93,15 +92,16 @@ sub parse {
             my $rel_table = $source->related_source($rel)->name;
             my $cond = (keys (%{$rel_info->{cond}}))[0];
             my ($refkey) = $cond =~ /^\w+\.(\w+)$/;
+            my ($key) = $rel_info->{cond}->{$cond} =~ /^\w+\.(\w+)$/;
             if($rel_table && $refkey)
             { 
                 $table->add_constraint(
                             type             => 'foreign_key', 
-                            name             => "fk_${rel}_id",
-                            fields           => $rel,
+                            name             => "fk_${key}",
+                            fields           => $key,
                             reference_fields => $refkey,
                             reference_table  => $rel_table,
-                                       );
+                );
             }
         }
     }