Description
Jonathan Druart
2021-04-15 10:12:06 UTC
Created attachment 119609 [details] [review] Bug 28152: Fix import_items row creation if duplicate barcode We are trying to insert "duplicate item barcode" into import_items.itemnumber (integer), it fails with "Incorrect integer value: 'duplicate item barcode' for column 'itemnumber' at row 1" To reproduce: Export a biblio with an item Import it => The item is not added, and there is no new row in import_items. The error only appears in the log if you comment the close STDERR and close STDOUT lines Hi Jonathan, I tried to test this but the patch didn't seem to fix the behaviour. What I did: 1) Exported record with an item, confirmed contained 952 data 2) Staged for import with default parameters 3) Imported record with Always add items 4) import_items contained a new row import_items_id | import_record_id | itemnumber | branchcode | status | marcxml | import_error | +-----------------+------------------+------------+------------+--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------+ | 1 | 1 | 0 | NULL | error | <?xml version="1.0" encoding="UTF-8"?> <collection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd" xmlns="http://www.loc.gov/MARC21/slim"> <record> <leader>00000 a </leader> <datafield tag="952" ind1=" " ind2=" "> <subfield code="0">0</subfield> <subfield code="1">0</subfield> <subfield code="4">0</subfield> <subfield code="6">_</subfield> <subfield code="7">0</subfield> <subfield code="8">REF</subfield> <subfield code="9">192</subfield> <subfield code="a">FPL</subfield> <subfield code="b">FPL</subfield> <subfield code="c">GEN</subfield> <subfield code="d">2014-09-04</subfield> <subfield code="p">39999000003697</subfield> <subfield code="r">2014-09-04</subfield> <subfield code="w">2014-09-04</subfield> <subfield code="y">BK</subfield> </datafield> </record> </collection> | NULL | 5) Checked imported record with View button in Manage staged MARC import and saw that there were no items associated with record 6) Applied patch and restarted services 7) Repeated steps 2-3 8) import_items contained a new row | 2 | 2 | NULL | NULL | error | <?xml version="1.0" encoding="UTF-8"?> <collection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd" xmlns="http://www.loc.gov/MARC21/slim"> <record> <leader>00000 a </leader> <datafield tag="952" ind1=" " ind2=" "> <subfield code="0">0</subfield> <subfield code="1">0</subfield> <subfield code="4">0</subfield> <subfield code="6">_</subfield> <subfield code="7">0</subfield> <subfield code="8">REF</subfield> <subfield code="9">192</subfield> <subfield code="a">FPL</subfield> <subfield code="b">FPL</subfield> <subfield code="c">GEN</subfield> <subfield code="d">2014-09-04</subfield> <subfield code="p">39999000003697</subfield> <subfield code="r">2014-09-04</subfield> <subfield code="w">2014-09-04</subfield> <subfield code="y">BK</subfield> </datafield> </record> </collection> | NULL | 9) Record still didn't have an item associated Please let me know if I've missed some step! Hi Hayley, what you are describing is the correct behaviour, the row in import_items should be there. The problem here is that, depending on the DBMS version, there is an error creating the row and it's missing. I should have added more information as I don't remember exactly the context, but a guess is that it may be an error with a more recent version, like MySQL 8. I saw this and I think I have been looking up that error in SQL at some point. I wonder if it got broken maybe by a change of sequence in parameters? Instead of removing it, I think the "duplicate item barcode" should go into import_items.import_error that is NULL in Hayley's test. (In reply to Katrin Fischer from comment #4) > I saw this and I think I have been looking up that error in SQL at some > point. I wonder if it got broken maybe by a change of sequence in parameters? > > Instead of removing it, I think the "duplicate item barcode" should go into > import_items.import_error that is NULL in Hayley's test. Hum, might be. But this is since commit 1dba9c6409d78cb1f90de6c1300cb5b63fb1b851 Date: Wed Oct 10 14:21:22 2012 -0500 Bug 7131: teach MARC import how to overlay items Looking at the code this 'import_error' column is empty for the last 9 years. Not sure it makes much sense to have this single error now. (In reply to Jonathan Druart from comment #6) > Looking at the code this 'import_error' column is empty for the last 9 > years. Not sure it makes much sense to have this single error now. Well, I deal a lot with old versions, I guess (and been around too long). Duplicate barcodes might appear without overlaying as well, just importing new data. Would it be hard to move it to the error message? Created attachment 129243 [details] [review] Bug 28152: Log the "duplicate item barcode" error Looking at the code this 'import_error' column is empty for the last 9 years. Not sure it makes much sense to have this single error now. commit 1dba9c6409d78cb1f90de6c1300cb5b63fb1b851 Date: Wed Oct 10 14:21:22 2012 -0500 Bug 7131: teach MARC import how to overlay items I failed to provide tests for this change. (In reply to Jonathan Druart from comment #1) > The error only appears in the log if you comment the close STDERR and > close STDOUT lines https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30738 should be able to help there... You can test this quite easily by first staging the record on intranet and then on the command line by running:
> $ perl misc/commit_file.pl --batch-number 8
> ... importing MARC records -- please wait
> C4::ImportBatch::BatchCommitItems(): DBI Exception: DBD::mysql::st execute failed: Incorrect integer value: 'duplicate item barcode' for column `koha_kohadev`.`import_items`.`itemnumber` at row 1 at /kohadevbox/koha/C4/ImportBatch.pm line 717
Note that the commit_file.pl might give other unrelated errors to this bug if you happen to give some record that it doesn't like but just ignore those...
Comment on attachment 129243 [details] [review] Bug 28152: Log the "duplicate item barcode" error Review of attachment 129243 [details] [review]: ----------------------------------------------------------------- Found a bug, moving to FQA ::: C4/ImportBatch.pm @@ +798,3 @@ > $updsth->execute(); > $num_items_errored++; > } else { The code under this else block is unmodified, thus broken. Created attachment 135070 [details] [review] Bug 28152: Log the "duplicate item barcode" error Looking at the code this 'import_error' column is empty for the last 9 years. Not sure it makes much sense to have this single error now. commit 1dba9c6409d78cb1f90de6c1300cb5b63fb1b851 Date: Wed Oct 10 14:21:22 2012 -0500 Bug 7131: teach MARC import how to overlay items Created attachment 135253 [details] [review] Bug 28152: Fix import_items row creation if duplicate barcode We are trying to insert "duplicate item barcode" into import_items.itemnumber (integer), it fails with "Incorrect integer value: 'duplicate item barcode' for column 'itemnumber' at row 1" To reproduce: Export a biblio with an item Import it => The item is not added, and there is no new row in import_items. The error only appears in the log if you comment the close STDERR and close STDOUT lines Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi> Created attachment 135254 [details] [review] Bug 28152: Log the "duplicate item barcode" error Looking at the code this 'import_error' column is empty for the last 9 years. Not sure it makes much sense to have this single error now. commit 1dba9c6409d78cb1f90de6c1300cb5b63fb1b851 Date: Wed Oct 10 14:21:22 2012 -0500 Bug 7131: teach MARC import how to overlay items Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi> Created attachment 135267 [details] [review] Bug 28152: Fix import_items row creation if duplicate barcode We are trying to insert "duplicate item barcode" into import_items.itemnumber (integer), it fails with "Incorrect integer value: 'duplicate item barcode' for column 'itemnumber' at row 1" To reproduce: Export a biblio with an item Import it => The item is not added, and there is no new row in import_items. The error only appears in the log if you comment the close STDERR and close STDOUT lines Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Created attachment 135268 [details] [review] Bug 28152: Log the "duplicate item barcode" error Looking at the code this 'import_error' column is empty for the last 9 years. Not sure it makes much sense to have this single error now. commit 1dba9c6409d78cb1f90de6c1300cb5b63fb1b851 Date: Wed Oct 10 14:21:22 2012 -0500 Bug 7131: teach MARC import how to overlay items Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Created attachment 135294 [details] [review] Bug 28152: Fix import_items row creation if duplicate barcode We are trying to insert "duplicate item barcode" into import_items.itemnumber (integer), it fails with "Incorrect integer value: 'duplicate item barcode' for column 'itemnumber' at row 1" To reproduce: Export a biblio with an item Import it => The item is not added, and there is no new row in import_items. The error only appears in the log if you comment the close STDERR and close STDOUT lines Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Created attachment 135295 [details] [review] Bug 28152: Log the "duplicate item barcode" error Looking at the code this 'import_error' column is empty for the last 9 years. Not sure it makes much sense to have this single error now. commit 1dba9c6409d78cb1f90de6c1300cb5b63fb1b851 Date: Wed Oct 10 14:21:22 2012 -0500 Bug 7131: teach MARC import how to overlay items Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Adding an additional QA stamp as I'm using this to test the Unit test patch in bug 30831 Pushed to master for 22.11, thanks! Pushed to 22.05.x for 22.05.01 pushed to 21.11.x for 21.11.07, thanks! Not backported to oldoldstable (21.05.x). Feel free to ask if it's needed. *** Bug 28128 has been marked as a duplicate of this bug. *** |