X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F99dbic_sqlt_parser.t;h=628f3cfdf6f7af5fc785bd8017807330d59a3694;hb=ed720bc5bef8e8497ef8c3a56efc55143a6bd465;hp=ccfc60abf910042a15514c495e8d88d4e49a0034;hpb=620df7e8b1f5c9f335989baff37ddfe763032765;p=dbsrgits%2FDBIx-Class.git diff --git a/t/99dbic_sqlt_parser.t b/t/99dbic_sqlt_parser.t index ccfc60a..628f3cf 100644 --- a/t/99dbic_sqlt_parser.t +++ b/t/99dbic_sqlt_parser.t @@ -35,43 +35,50 @@ my @sources = grep $schema->sources ; -{ +my $idx_exceptions = { + 'Artwork' => -1, + 'ForceForeign' => -1, + 'LinerNotes' => -1, + 'TwoKeys' => -1, # TwoKeys has the index turned off on the rel def +}; + +{ my $sqlt_schema = create_schema({ schema => $schema, args => { parser_args => { } } }); foreach my $source_name (@sources) { my $table = get_table($sqlt_schema, $schema, $source_name); my $fk_count = scalar(grep { $_->type eq 'FOREIGN KEY' } $table->get_constraints); + $fk_count += $idx_exceptions->{$source_name} || 0; my @indices = $table->get_indices; my $index_count = scalar(@indices); - $index_count++ if ($source_name eq 'TwoKeys'); # TwoKeys has the index turned off on the rel def is($index_count, $fk_count, "correct number of indices for $source_name with no args"); - + for my $index (@indices) { my $source = $schema->source($source_name); - my @pks = $source->primary_columns; - my @idx_cols = $index->fields; - ok ( !eq_set(\@pks, \@idx_cols), "no additional index for the primary columns exists in $source_name"); + my $pk_test = join("\x00", $source->primary_columns); + my $idx_test = join("\x00", $index->fields); + isnt ( $pk_test, $idx_test, "no additional index for the primary columns exists in $source_name"); } } } -{ +{ my $sqlt_schema = create_schema({ schema => $schema, args => { parser_args => { add_fk_index => 1 } } }); - foreach my $source (@sources) { - my $table = get_table($sqlt_schema, $schema, $source); + foreach my $source_name (@sources) { + my $table = get_table($sqlt_schema, $schema, $source_name); my $fk_count = scalar(grep { $_->type eq 'FOREIGN KEY' } $table->get_constraints); + $fk_count += $idx_exceptions->{$source_name} || 0; my @indices = $table->get_indices; my $index_count = scalar(@indices); - $index_count++ if ($source eq 'TwoKeys'); # TwoKeys has the index turned off on the rel def - is($index_count, $fk_count, "correct number of indices for $source with add_fk_index => 1"); + is($index_count, $fk_count, "correct number of indices for $source_name with add_fk_index => 1"); } } -{ +{ my $sqlt_schema = create_schema({ schema => $schema, args => { parser_args => { add_fk_index => 0 } } }); foreach my $source (@sources) { @@ -83,7 +90,7 @@ my @sources = grep } } -{ +{ { package # hide from PAUSE DBICTest::Schema::NoViewDefinition;