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

(-)a/t/db_dependent/TestBuilder.t (-1 / +22 lines)
Lines 21-27 use Modern::Perl; Link Here
21
21
22
use utf8;
22
use utf8;
23
23
24
use Test::More tests => 14;
24
use Test::More tests => 15;
25
use Test::Warn;
25
use Test::Warn;
26
use File::Basename qw(dirname);
26
use File::Basename qw(dirname);
27
27
Lines 477-479 subtest 'build_sample_biblio() tests' => sub { Link Here
477
477
478
    $schema->storage->txn_rollback;
478
    $schema->storage->txn_rollback;
479
};
479
};
480
481
subtest 'Existence of object is only checked using primary keys' => sub {
482
483
    plan tests => 1;
484
485
    $schema->storage->txn_begin;
486
487
    my $biblio = $builder->build_sample_biblio();
488
    my $item1 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber });
489
    my $item2 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber });
490
    warnings_are {
491
      $builder->build_object({
492
        class => 'Koha::Holds',
493
        value  => {
494
            biblionumber => $biblio->biblionumber
495
        }
496
      });
497
    } [], "No warning about query returning more than one row";
498
499
    $schema->storage->txn_rollback;
500
};
(-)a/t/lib/TestBuilder.pm (-2 / +8 lines)
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
- 

Return to bug 28479