From f74fa05eced7e74e35932c9e3009c7ce9b5f6255 Mon Sep 17 00:00:00 2001 From: Sophie Meynieux Date: Sun, 10 Jun 2012 17:01:26 +0200 Subject: [PATCH] Bug 7329 [Followup] : when reverting an import, keep matching biblionumber in batch table, if items are not deleted because they are issued. Signed-off-by: Katrin Fischer Signed-off-by: Paul Poulain Signed-off-by: Chris Cormack (cherry picked from commit d92874095256058756b08aec4fcaf7b4316bca7f) --- C4/ImportBatch.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm index 9aad8c4383..3e0e04f02b 100644 --- a/C4/ImportBatch.pm +++ b/C4/ImportBatch.pm @@ -616,7 +616,8 @@ sub BatchRevertBibRecords { $num_items_deleted += BatchRevertItems($rowref->{'import_record_id'}, $rowref->{'matched_biblionumber'}); SetImportRecordStatus($rowref->{'import_record_id'}, 'reverted'); } - my $sth2 = $dbh->prepare_cached("UPDATE import_biblios LEFT JOIN import_items USING (import_record_id) SET matched_biblionumber = NULL WHERE import_record_id = ? AND status != 'imported'" ); + # remove matched_biblionumber only if there is no 'imported' item left + my $sth2 = $dbh->prepare_cached("UPDATE import_biblios SET matched_biblionumber = NULL WHERE import_record_id = ? AND NOT EXISTS (SELECT * FROM import_items WHERE import_items.import_record_id=import_biblios.import_record_id and status='imported')" ); $sth2->execute($rowref->{'import_record_id'}); } -- 2.39.5