[Koha-bugs] [Bug 6199] Allow bulkmarcimport to blank duplicate barcodes rather than skipping items

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Wed Jun 15 10:37:51 CEST 2011


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=6199

Magnus Enger <magnus at enger.priv.no> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |magnus at enger.priv.no
       Patch Status|Needs Signoff               |Failed QA

--- Comment #11 from Magnus Enger <magnus at enger.priv.no> 2011-06-15 08:37:51 UTC ---
Downloaded the 2 sample files as sample6199-1.mrc and sample6199-2.mrc. 

mysql> select count(*) from items;
+----------+
| count(*) |
+----------+
|      142 |
+----------+

* TEST BEFORE PATCH, SAMPLE 1

$ perl misc/migration_tools/bulkmarcimport.pl -b -v -file sample6199-1.mrc -l
test-1-pre.txt
.Item not added (bib 5173, item tag #2, barcode duplicate): duplicate barcode
duplicate
..Item not added (bib 5175, item tag #1, barcode duplicate2): duplicate barcode
duplicate2
.
4 MARC records done in 0.396538972854614 seconds

$ more test-1-pre.txt 
id;operation;status
5173;insert;ok
5173;insert;ok
5174;insert;ok
5174;insert;ok
5175;insert;ok
5175;insert;ok
5176;insert;ok
5176;insert;ok
file : sample6199-1.mrc
4 MARC records done in 0.396538972854614 seconds

mysql> select count(*) from items;
+----------+
| count(*) |
+----------+
|      145 |
+----------+

* TEST BEFORE PATCH, SAMPLE 2

$ perl misc/migration_tools/bulkmarcimport.pl -b -v -file sample6199-2.mrc -l
test-2-pre.txt
.Item not added (bib 5177, item tag #1, barcode barcode1): invalid homebranch C
.Item not added (bib 5178, item tag #1, barcode barcode1): invalid homebranch C
.Item not added (bib 5179, item tag #1, barcode barcode2): invalid homebranch C
.Item not added (bib 5180, item tag #1, barcode barcode2): invalid homebranch C
.Item not added (bib 5181, item tag #1, barcode barcode3): invalid homebranch C
5 MARC records done in 0.272064924240112 seconds

mysql> select count(*) from items;
+----------+
| count(*) |
+----------+
|      145 |
+----------+

So, i create a library with branchcode C and repeat the import: 

$ perl misc/migration_tools/bulkmarcimport.pl -b -v -file sample6199-2.mrc -l
test-2-pre.txt
..Item not added (bib 5183, item tag #1, barcode barcode1): duplicate barcode
barcode1
..Item not added (bib 5185, item tag #1, barcode barcode2): duplicate barcode
barcode2
.
5 MARC records done in 0.248023986816406 seconds

$ more test-2-pre.txt 
id;operation;status
5182;insert;ok
5182;insert;ok
5183;insert;ok
5183;insert;ok
5184;insert;ok
5184;insert;ok
5185;insert;ok
5185;insert;ok
5186;insert;ok
5186;insert;ok
file : sample6199-2.mrc
5 MARC records done in 0.248023986816406 seconds

mysql> select count(*) from items;
+----------+
| count(*) |
+----------+
|      148 |
+----------+

Before proceeding i load a dump i did of my database before doing the first
import, and reindex, then apply the patch and do: 

mysql> select count(*) from items;
+----------+
| count(*) |
+----------+
|      142 |
+----------+

To verify that the -dedupbarcodes is present in the script:
$ perl misc/migration_tools/bulkmarcimport.pl -h

* TEST AFTER PATCH, SAMPLE 1

$ perl misc/migration_tools/bulkmarcimport.pl -b -v -file sample6199-1.mrc -l
test-1-post.txt -dedupbarcode
....
4 MARC records done in 0.420637130737305 seconds

$ more test-1-post.txt 
id;operation;status
5173;insert;ok
5173;insert;ok
5173;insert;ok
5174;insert;ok
5174;insert;ok
5175;insert;ok
5175;insert;ok
5175;insert;ok
5176;insert;ok
5176;insert;ok
file : sample6199-1.mrc
4 MARC records done in 0.420637130737305 seconds

mysql> select count(*) from items;
+----------+
| count(*) |
+----------+
|      145 |
+----------+

* TEST AFTER PATCH, SAMPLE 2

$ perl misc/migration_tools/bulkmarcimport.pl -b -v -file sample6199-2.mrc -l
test-2-post.txt -dedupbarcode
.....
5 MARC records done in 0.232513904571533 seconds

$ more test-2-post.txt 
id;operation;status
5177;insert;ok
5177;insert;ok
5178;insert;ok
5178;insert;ok
5178;insert;ok
5179;insert;ok
5179;insert;ok
5180;insert;ok
5180;insert;ok
5180;insert;ok
5181;insert;ok
5181;insert;ok
file : sample6199-2.mrc
5 MARC records done in 0.214529037475586 seconds

mysql> select count(*) from items;
+----------+
| count(*) |
+----------+
|      148 |
+----------+

* DOUBLE CHECKING

mysql> select biblionumber, barcode from items where biblionumber > 5172;
+--------------+------------+
| biblionumber | barcode    |
+--------------+------------+
|         5173 | duplicate  |
|         5174 | duplicate2 |
|         5176 | unique     |
|         5177 | barcode1   |
|         5179 | barcode2   |
|         5181 | barcode3   |
+--------------+------------+

Checking the number of items manually in the OPAC: 

5173: 1 item
5174: 1 
5175: 0 
5176: 1
5177: 1
5178: 0
5179: 1
5180: 0
5181: 1

Here's the output of "show create table items;": 

CREATE TABLE `items` (
  `itemnumber` int(11) NOT NULL AUTO_INCREMENT,
  `biblionumber` int(11) NOT NULL DEFAULT '0',
  `biblioitemnumber` int(11) NOT NULL DEFAULT '0',
  `barcode` varchar(20) DEFAULT NULL,
  `dateaccessioned` date DEFAULT NULL,
  `booksellerid` mediumtext,
  `homebranch` varchar(10) DEFAULT NULL,
  `price` decimal(8,2) DEFAULT NULL,
  `replacementprice` decimal(8,2) DEFAULT NULL,
  `replacementpricedate` date DEFAULT NULL,
  `datelastborrowed` date DEFAULT NULL,
  `datelastseen` date DEFAULT NULL,
  `stack` tinyint(1) DEFAULT NULL,
  `notforloan` tinyint(1) NOT NULL DEFAULT '0',
  `damaged` tinyint(1) NOT NULL DEFAULT '0',
  `itemlost` tinyint(1) NOT NULL DEFAULT '0',
  `wthdrawn` tinyint(1) NOT NULL DEFAULT '0',
  `itemcallnumber` varchar(255) DEFAULT NULL,
  `issues` smallint(6) DEFAULT NULL,
  `renewals` smallint(6) DEFAULT NULL,
  `reserves` smallint(6) DEFAULT NULL,
  `restricted` tinyint(1) DEFAULT NULL,
  `itemnotes` mediumtext,
  `holdingbranch` varchar(10) DEFAULT NULL,
  `paidfor` mediumtext,
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE
CURRENT_TIMESTAMP,
  `location` varchar(80) DEFAULT NULL,
  `permanent_location` varchar(80) DEFAULT NULL,
  `onloan` date DEFAULT NULL,
  `cn_source` varchar(10) DEFAULT NULL,
  `cn_sort` varchar(30) DEFAULT NULL,
  `ccode` varchar(10) DEFAULT NULL,
  `materials` varchar(10) DEFAULT NULL,
  `uri` varchar(255) DEFAULT NULL,
  `itype` varchar(10) DEFAULT NULL,
  `more_subfields_xml` longtext,
  `enumchron` text,
  `copynumber` varchar(32) DEFAULT NULL,
  `stocknumber` varchar(32) DEFAULT NULL,
  PRIMARY KEY (`itemnumber`),
  UNIQUE KEY `itembarcodeidx` (`barcode`),
  UNIQUE KEY `itemstocknumberidx` (`stocknumber`),
  KEY `itembinoidx` (`biblioitemnumber`),
  KEY `itembibnoidx` (`biblionumber`),
  KEY `homebranch` (`homebranch`),
  KEY `holdingbranch` (`holdingbranch`),
  CONSTRAINT `items_ibfk_1` FOREIGN KEY (`biblioitemnumber`) REFERENCES
`biblioitems` (`biblioitemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `items_ibfk_2` FOREIGN KEY (`homebranch`) REFERENCES `branches`
(`branchcode`) ON UPDATE CASCADE,
  CONSTRAINT `items_ibfk_3` FOREIGN KEY (`holdingbranch`) REFERENCES `branches`
(`branchcode`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=151 DEFAULT CHARSET=utf8

* CONCLUSION

With the patch applied and -dedupbarcode there are no warnings about duplicate
barcodes and the log file produced by -l seems to indicate that more items are
added, but the items do not show up in the items table. Marking as failed QA. 

Also: The POD says the option is called -dedupbarcodes but GetOptions is
looking for dedupbarcode without the s: 'dedupbarcode' => \$dedup_barcode,

-- 
Configure bugmail: http://bugs.koha-community.org/bugzilla3/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA Contact for the bug.


More information about the Koha-bugs mailing list