added branch no_duplicate_indexes_for_pk_cols with test and fix
[dbsrgits/DBIx-Class.git] / lib / SQL / Translator / Parser / DBIx / Class.pm
index 5d146f8..2aa5098 100644 (file)
@@ -210,10 +210,15 @@ sub parse {
             {
                 # Constraints are added only if applicable
                 next unless $fk_constraint;
-
+                
                 # Make sure we dont create the same foreign key constraint twice
                 my $key_test = join("\x00", sort @keys);
                 next if $created_FK_rels{$rel_table}->{$key_test};
+                
+                # Make sure we dont create additional indexes for the
+                # primary columns
+                my $pk_test = join("\x00", sort @primary);
+                next if $key_test eq $pk_test;
 
                 if (scalar(@keys)) {
 
@@ -379,7 +384,14 @@ from a DBIx::Class::Schema instance
  my $schema = MyApp::Schema->connect;
  my $trans  = SQL::Translator->new (
       parser      => 'SQL::Translator::Parser::DBIx::Class',
-      parser_args => { package => $schema },
+      parser_args => {
+          package => $schema,
+          # to explicitly specify which ResultSources are to be parsed
+          sources => [qw/
+            Artist
+            CD
+          /],
+      },
       producer    => 'SQLite',
      ) or die SQL::Translator->error;
  my $out = $trans->translate() or die $trans->error;