Lines 334-339
sub _getForeignKeys {
Link Here
|
334 |
|
334 |
|
335 |
my ( @foreign_keys, $check_dupl ); |
335 |
my ( @foreign_keys, $check_dupl ); |
336 |
my @relationships = $source->relationships; |
336 |
my @relationships = $source->relationships; |
|
|
337 |
my $col_names = {}; |
337 |
for my $rel_name( @relationships ) { |
338 |
for my $rel_name( @relationships ) { |
338 |
my $rel_info = $source->relationship_info($rel_name); |
339 |
my $rel_info = $source->relationship_info($rel_name); |
339 |
if( $rel_info->{attrs}->{is_foreign_key_constraint} ) { |
340 |
if( $rel_info->{attrs}->{is_foreign_key_constraint} ) { |
Lines 342-353
sub _getForeignKeys {
Link Here
|
342 |
|
343 |
|
343 |
my @keys; |
344 |
my @keys; |
344 |
while( my ($col_fk_name, $col_name) = each(%{$rel_info->{cond}}) ) { |
345 |
while( my ($col_fk_name, $col_name) = each(%{$rel_info->{cond}}) ) { |
|
|
346 |
# If we have more than one FK on the same column, we only generate values for the first one |
347 |
next if exists $col_names->{$col_name}; |
345 |
$col_name =~ s|self.(\w+)|$1|; |
348 |
$col_name =~ s|self.(\w+)|$1|; |
346 |
$col_fk_name =~ s|foreign.(\w+)|$1|; |
349 |
$col_fk_name =~ s|foreign.(\w+)|$1|; |
347 |
push @keys, { |
350 |
push @keys, { |
348 |
col_name => $col_name, |
351 |
col_name => $col_name, |
349 |
col_fk_name => $col_fk_name, |
352 |
col_fk_name => $col_fk_name, |
350 |
}; |
353 |
}; |
|
|
354 |
$col_names->{$col_name} = 1; |
351 |
} |
355 |
} |
352 |
# check if the combination table and keys is unique |
356 |
# check if the combination table and keys is unique |
353 |
# so skip double belongs_to relations (as in Biblioitem) |
357 |
# so skip double belongs_to relations (as in Biblioitem) |
354 |
- |
|
|