|
Lines 231-238
sub _create_links {
Link Here
|
| 231 |
if( $cnt_scalar == @$keys ) { |
231 |
if( $cnt_scalar == @$keys ) { |
| 232 |
# if one or more fk cols are null, the FK constraint will not be forced |
232 |
# if one or more fk cols are null, the FK constraint will not be forced |
| 233 |
return {} if $cnt_null > 0; |
233 |
return {} if $cnt_null > 0; |
|
|
234 |
|
| 234 |
# does the record exist already? |
235 |
# does the record exist already? |
| 235 |
return {} if $self->schema->resultset($linked_tbl)->find( $fk_value ); |
236 |
my @pks = $self->schema->source( $linked_tbl )->primary_columns; |
|
|
237 |
my %fk_pk_value; |
| 238 |
for (@pks) { |
| 239 |
$fk_pk_value{$_} = $fk_value->{$_} if defined $fk_value->{$_}; |
| 240 |
} |
| 241 |
return {} if !(keys %fk_pk_value); |
| 242 |
return {} if $self->schema->resultset($linked_tbl)->find( \%fk_pk_value ); |
| 236 |
} |
243 |
} |
| 237 |
# create record with a recursive build call |
244 |
# create record with a recursive build call |
| 238 |
my $row = $self->build({ source => $linked_tbl, value => $fk_value }); |
245 |
my $row = $self->build({ source => $linked_tbl, value => $fk_value }); |
| 239 |
- |
|
|