From fdc933adb49256bb0b61a2189126dc4ad8c37143 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 Signed-off-by: Tomas Cohen Arazi --- t/lib/TestBuilder.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/t/lib/TestBuilder.pm b/t/lib/TestBuilder.pm index 94ffa97510..28a55fd4c3 100644 --- a/t/lib/TestBuilder.pm +++ b/t/lib/TestBuilder.pm @@ -123,9 +123,16 @@ sub build { # loop thru all fk and create linked records if needed # fills remaining entries in $col_values my $foreign_keys = $self->_getForeignKeys( { source => $source } ); + my $col_names = {}; for my $fk ( @$foreign_keys ) { # skip when FK points to itself: e.g. borrowers:guarantorid next if $fk->{source} eq $source; + + # If we have more than one FK on the same column, we only generate values for the first one + next + if scalar @{ $fk->{keys} } == 1 + && exists $col_names->{ $fk->{keys}->[0]->{col_name} }; + my $keys = $fk->{keys}; my $tbl = $fk->{source}; my $res = $self->_create_links( $tbl, $keys, $col_values, $value ); @@ -133,6 +140,9 @@ sub build { foreach( keys %$res ) { # save new values $col_values->{$_} = $res->{$_}; } + + $col_names->{ $fk->{keys}->[0]->{col_name} } = 1 + if scalar @{ $fk->{keys} } == 1 } # store this record and return hashref -- 2.39.5