my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
+# Remove invalid guarantorid's as long as we have no FK
+$dbh->do("UPDATE borrowers b1 LEFT JOIN borrowers b2 ON b2.borrowernumber=b1.guarantorid SET b1.guarantorid=NULL where b1.guarantorid IS NOT NULL AND b2.borrowernumber IS NULL");
+
my $library1 = $builder->build({
source => 'Branch',
});
categorycode=>'STAFFER',
branchcode => $library3->{branchcode},
dateexpiry => '2015-01-01',
+ guarantorid=> undef,
},
});
my $bor1inlist = $borrower1->{borrowernumber};
categorycode=>'STAFFER',
branchcode => $library3->{branchcode},
dateexpiry => '2015-01-01',
+ guarantorid=> undef,
},
});
categorycode=>'KIDclamp',
branchcode => $library3->{branchcode},
dateexpiry => '2015-01-01',
+ guarantorid=> undef, # will be filled later
},
});
},
});
-# In some dirty DB, the guarantorid is set to a non existent patron id
-# If we pick it, then the tests will fail
-# This should not be needed, we should have a FK on the guarantorid instead
-Koha::Patrons->search({ guarantorid => { -in => [ $borrower1->{borrowernumber}, $borrower2->{borrowernumber} ] }})->update({ guarantorid => undef });
-
my $owner = AddMember (categorycode => 'STAFFER', branchcode => $library2->{branchcode} );
my $list1 = AddPatronList( { name => 'Test List 1', owner => $owner } );
my @listpatrons = ($bor1inlist, $bor2inlist);