From 1a8f64555c96aa8b033d7fdefb61dbe2db806c7e Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 12 Jul 2022 09:11:12 +0200 Subject: [PATCH] Bug 31133: Don't generate values for more than one FK --- t/lib/TestBuilder.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/t/lib/TestBuilder.pm b/t/lib/TestBuilder.pm index 94ffa975103..7ebefd32115 100644 --- a/t/lib/TestBuilder.pm +++ b/t/lib/TestBuilder.pm @@ -334,6 +334,7 @@ sub _getForeignKeys { my ( @foreign_keys, $check_dupl ); my @relationships = $source->relationships; + my $col_names = {}; for my $rel_name( @relationships ) { my $rel_info = $source->relationship_info($rel_name); if( $rel_info->{attrs}->{is_foreign_key_constraint} ) { @@ -342,12 +343,15 @@ sub _getForeignKeys { my @keys; while( my ($col_fk_name, $col_name) = each(%{$rel_info->{cond}}) ) { + # If we have more than one FK on the same column, we only generate values for the first one + next if exists $col_names->{$col_name}; $col_name =~ s|self.(\w+)|$1|; $col_fk_name =~ s|foreign.(\w+)|$1|; push @keys, { col_name => $col_name, col_fk_name => $col_fk_name, }; + $col_names->{$col_name} = 1; } # check if the combination table and keys is unique # so skip double belongs_to relations (as in Biblioitem) -- 2.25.1