use Modern::Perl;
-use Koha::Database;
-use C4::Biblio;
-use C4::Items;
-use Koha::Biblios;
-use Koha::Items;
+use Koha::Database qw( schema );
+use C4::Biblio qw( AddBiblio );
+use Koha::Biblios qw( _type );
+use Koha::Items qw( _type );
use Koha::DateUtils qw( dt_from_string );
use Bytes::Random::Secure;
-use Carp;
-use Module::Load;
+use Carp qw( carp );
+use Module::Load qw( load );
use String::Random;
use constant {
if( $cnt_scalar == @$keys ) {
# if one or more fk cols are null, the FK constraint will not be forced
return {} if $cnt_null > 0;
+
# does the record exist already?
- return {} if $self->schema->resultset($linked_tbl)->find( $fk_value );
+ my @pks = $self->schema->source( $linked_tbl )->primary_columns;
+ my %fk_pk_value;
+ for (@pks) {
+ $fk_pk_value{$_} = $fk_value->{$_} if defined $fk_value->{$_};
+ }
+ return {} if !(keys %fk_pk_value);
+ return {} if $self->schema->resultset($linked_tbl)->find( \%fk_pk_value );
}
# create record with a recursive build call
my $row = $self->build({ source => $linked_tbl, value => $fk_value });
},
AuthHeader => {
marcxml => '',
- }
+ },
+ BorrowerAttributeType => {
+ mandatory => 0,
+ },
};
}