[Bast-commits] r4104 - DBIx-Class/0.08/branches/versioned_enhancements/lib/SQL/Translator/Parser/DBIx

captainL at dev.catalyst.perl.org captainL at dev.catalyst.perl.org
Wed Feb 27 15:12:12 GMT 2008


Author: captainL
Date: 2008-02-27 15:12:12 +0000 (Wed, 27 Feb 2008)
New Revision: 4104

Modified:
   DBIx-Class/0.08/branches/versioned_enhancements/lib/SQL/Translator/Parser/DBIx/Class.pm
Log:
fixed behaviour or is_foreign_key_constraint and unique index names

Modified: DBIx-Class/0.08/branches/versioned_enhancements/lib/SQL/Translator/Parser/DBIx/Class.pm
===================================================================
--- DBIx-Class/0.08/branches/versioned_enhancements/lib/SQL/Translator/Parser/DBIx/Class.pm	2008-02-27 15:11:21 UTC (rev 4103)
+++ DBIx-Class/0.08/branches/versioned_enhancements/lib/SQL/Translator/Parser/DBIx/Class.pm	2008-02-27 15:12:12 UTC (rev 4104)
@@ -162,16 +162,20 @@
                 # If the sets are different, then we assume it's a foreign key from
                 # us to another table.
                 # OR: If is_foreign_key_constraint attr is explicity set (or set to false) on the relation
-                if ( ! exists $created_FK_rels{$rel_table}->{$key_test} &&
-                     ( exists $rel_info->{attrs}{is_foreign_key_constraint} ?
-                       $rel_info->{attrs}{is_foreign_key_constraint} :
-                       !$source->compare_relationship_keys(\@keys, \@primary)
-		     )
-                   )
-                {
-                    $created_FK_rels{$rel_table}->{$key_test} = 1;
-                    if (scalar(@keys)) {
-                        $table->add_constraint(
+                next if ( exists $created_FK_rels{$rel_table}->{$key_test} );
+                if ( exists $rel_info->{attrs}{is_foreign_key_constraint}) {
+                  # not is this attr set to 0 but definitely if set to 1
+                  next unless ($rel_info->{attrs}{is_foreign_key_constraint});
+                } else {
+                  # not if might have
+                  # next if ($rel_info->{attrs}{accessor} eq 'single' && exists $rel_info->{attrs}{join_type} && uc($rel_info->{attrs}{join_type}) eq 'LEFT');
+                  # not sure about this one
+                  next if $source->compare_relationship_keys(\@keys, \@primary);
+                }
+
+                $created_FK_rels{$rel_table}->{$key_test} = 1;
+                if (scalar(@keys)) {
+                  $table->add_constraint(
                                     type             => 'foreign_key',
                                     name             => $table->name . "_fk_$keys[0]",
                                     fields           => \@keys,
@@ -179,15 +183,13 @@
                                     reference_table  => $rel_table,
                                     on_delete        => $on_delete,
                                     on_update        => $on_update
-                        );
+                  );
                     
-                        my $index = $table->add_index(
-                                    name   => $keys[0],
+                  my $index = $table->add_index(
+                                    name   => join('_', @keys),
                                     fields => \@keys,
                                     type   => 'NORMAL',
-                        );
-                    }
-
+                  );
                 }
             }
         }




More information about the Bast-commits mailing list