View | Details | Raw Unified | Return to bug 31133
Collapse All | Expand All

(-)a/t/lib/TestBuilder.pm (-1 / +10 lines)
Lines 123-131 sub build { Link Here
123
    # loop thru all fk and create linked records if needed
123
    # loop thru all fk and create linked records if needed
124
    # fills remaining entries in $col_values
124
    # fills remaining entries in $col_values
125
    my $foreign_keys = $self->_getForeignKeys( { source => $source } );
125
    my $foreign_keys = $self->_getForeignKeys( { source => $source } );
126
    my $col_names = {};
126
    for my $fk ( @$foreign_keys ) {
127
    for my $fk ( @$foreign_keys ) {
127
        # skip when FK points to itself: e.g. borrowers:guarantorid
128
        # skip when FK points to itself: e.g. borrowers:guarantorid
128
        next if $fk->{source} eq $source;
129
        next if $fk->{source} eq $source;
130
131
        # If we have more than one FK on the same column, we only generate values for the first one
132
        next
133
          if scalar @{ $fk->{keys} } == 1
134
          && exists $col_names->{ $fk->{keys}->[0]->{col_name} };
135
129
        my $keys = $fk->{keys};
136
        my $keys = $fk->{keys};
130
        my $tbl = $fk->{source};
137
        my $tbl = $fk->{source};
131
        my $res = $self->_create_links( $tbl, $keys, $col_values, $value );
138
        my $res = $self->_create_links( $tbl, $keys, $col_values, $value );
Lines 133-138 sub build { Link Here
133
        foreach( keys %$res ) { # save new values
140
        foreach( keys %$res ) { # save new values
134
            $col_values->{$_} = $res->{$_};
141
            $col_values->{$_} = $res->{$_};
135
        }
142
        }
143
144
        $col_names->{ $fk->{keys}->[0]->{col_name} } = 1
145
          if scalar @{ $fk->{keys} } == 1
136
    }
146
    }
137
147
138
    # store this record and return hashref
148
    # store this record and return hashref
139
- 

Return to bug 31133