[Bug 26328] New: barcode.pl: ValueBuilder::incremental should cast barcode to unsigned integer
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 Bug ID: 26328 Summary: barcode.pl: ValueBuilder::incremental should cast barcode to unsigned integer Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Cataloging Assignee: koha-bugs@lists.koha-community.org Reporter: pablo.bianchi@gmail.com QA Contact: testopia@bugs.koha-community.org CC: m.de.rooy@rijksmuseum.nl When using barcode.pl or barcode_manual.pl:, if a barcode is "85350E65", because of the "E" the value builder interprets it as having exponential notation: "8.535e69". This happens on C4::Barcodes::ValueBuilder::incremental, on get_barcode(). When it says SELECT MAX(ABS(barcode)) FROM items; probably should be instead SELECT MAX(ABS(CAST(barcode AS UNSIGNED))) FROM items; -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dcook@prosentient.com.au --- Comment #1 from David Cook <dcook@prosentient.com.au> --- That's an interesting one. Your suggestion returns a value of 9223372036854775807. I would say that is an undesirable outcome as well. It's probably better to use something like this: SELECT MAX(ABS(barcode)) FROM items WHERE barcode REGEXP '^[0-9]+$'; -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 --- Comment #2 from Pablo AB <pablo.bianchi@gmail.com> --- You are right. On my tests: SELECT barcode FROM items ORDER BY ABS(CAST(barcode AS UNSIGNED)) DESC LIMIT 5; 770101E1 → 770101 (CAST on SELECT) SELECT barcode FROM items ORDER BY ABS(barcode) DESC LIMIT 5; 85350E65 → 8.535e69 (ABS on SELECT) Your proposal seems the way to go. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 Pablo AB <pablo.bianchi@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|barcode.pl: |barcode.pl: |ValueBuilder::incremental |ValueBuilder::incremental |should cast barcode to |should filter non-natural |unsigned integer |numbers -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 --- Comment #3 from David Cook <dcook@prosentient.com.au> --- I have a long TODO list, but I can look at adding a patch for this down the road. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 --- Comment #4 from David Cook <dcook@prosentient.com.au> --- I actually ran into this problem again today, and at the moment the query I like best is actually the following: SELECT max(cast(barcode as unsigned)) from items; I'll write up a patch now... -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 --- Comment #5 from David Cook <dcook@prosentient.com.au> --- Created attachment 114179 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=114179&action=edit Bug 26328: Cast barcode from varchar to integer for incremental barcode Without this patch, the incremental barcode generation will treat 978e0143019375 as having an exponent and interpret it as a very large number. With this patch, the incremental barcode generation will first cast barcode varchar strings to integers before finding a max() value. In this case 978e0143019375 becomes 978 instead of 1.7976931348623157e308 Test plan: 0. Using koha-testing-docker Before applying patch: 1. Go to http://localhost:8081/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=autobarcode 2. Set to "generated in the form 1, 2, 3" 3. Go to http://localhost:8081/cgi-bin/koha/cataloguing/additem.pl?biblionumber=1#additema&searchid=scs_1607059974968 4. Add item with barcode 978e0143019375 5. Click "p - Barcode" 6. Note the barcode is "Inf" After applying patch: 1. Go to http://localhost:8081/cgi-bin/koha/cataloguing/additem.pl?biblionumber=1#additema&searchid=scs_1607059974968 2. Click "p - Barcode" 3. Note the barcode is "39999000019194" -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|barcode.pl: |incremental barcode |ValueBuilder::incremental |generation fails when |should filter non-natural |incorrectly converting |numbers |strings to numbers -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|enhancement |normal Assignee|koha-bugs@lists.koha-commun |dcook@prosentient.com.au |ity.org | -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 --- Comment #6 from Pablo AB <pablo.bianchi@gmail.com> --- (In reply to David Cook from comment #4)
I actually ran into this problem again today, and at the moment the query I like best is actually the following:
SELECT max(cast(barcode as unsigned)) from items;
Why you like the most this one (except for the ABS identical to my first suggestion), instead of your alternative con comment 1? I remember that at the time your suggestion seems better. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 --- Comment #7 from David Cook <dcook@prosentient.com.au> --- (In reply to Pablo AB from comment #6)
Why you like the most this one (except for the ABS identical to my first suggestion), instead of your alternative con comment 1? I remember that at the time your suggestion seems better.
Option 1: SELECT MAX(ABS(barcode)) FROM items WHERE barcode REGEXP '^[0-9]+$'; This query won't generate any warnings, so that's good. But it's also fairly long and a little complex. Option 2: SELECT max(cast(barcode as unsigned)) from items; This query will show "Truncated incorrect..." warnings, but it's simpler/easier to read/maintain. -- In the end, it doesn't really matter too much I think. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 Amit Gupta <amitddng135@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |amit.gupta@informaticsgloba | |l.com, | |amitddng135@gmail.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |Academy -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 Aleisha Amohia <aleisha@catalyst.net.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |aleisha@catalyst.net.nz --- Comment #8 from Aleisha Amohia <aleisha@catalyst.net.nz> --- Is this ready for testing? If not can you please update the status appropriately? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 --- Comment #9 from David Cook <dcook@prosentient.com.au> --- (In reply to Aleisha Amohia from comment #8)
Is this ready for testing? If not can you please update the status appropriately?
It was never properly signed off, so I think it's still in Needs Signoff, unfortunately. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 Catherine <catherinem2003@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Failed QA CC| |catherinem2003@gmail.com --- Comment #10 from Catherine <catherinem2003@gmail.com> --- I followed the test plan, however it did not work accordingly. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 --- Comment #11 from David Cook <dcook@prosentient.com.au> --- (In reply to Catherine from comment #10)
I followed the test plan, however it did not work accordingly.
Can you describe how it did not work? It worked great last time I looked at it. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 --- Comment #12 from Catherine <catherinem2003@gmail.com> --- Hi David, after applying the patch, I did step 2 however "39999000019194" did not appear. Nothing changed when I did step 2. Possible that I made an error during the test plan, so someone else should test again. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 --- Comment #13 from David Cook <dcook@prosentient.com.au> --- (In reply to Catherine from comment #12)
Hi David, after applying the patch, I did step 2 however "39999000019194" did not appear. Nothing changed when I did step 2. Possible that I made an error during the test plan, so someone else should test again.
Hmm weird. I'll give it another go sometime too. Were you using a fresh koha-testing-docker? Or were you testing it with a different Koha dev setup? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 Marjorie Barry-Vila <marjorie.barry-vila@collecto.ca> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |marjorie.barry-vila@collect | |o.ca -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 ByWater Sandboxes <bws.sandboxes@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #114179|0 |1 is obsolete| | --- Comment #14 from ByWater Sandboxes <bws.sandboxes@gmail.com> --- Created attachment 131592 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=131592&action=edit Bug 26328: Cast barcode from varchar to integer for incremental barcode Without this patch, the incremental barcode generation will treat 978e0143019375 as having an exponent and interpret it as a very large number. With this patch, the incremental barcode generation will first cast barcode varchar strings to integers before finding a max() value. In this case 978e0143019375 becomes 978 instead of 1.7976931348623157e308 Test plan: 0. Using koha-testing-docker Before applying patch: 1. Go to http://localhost:8081/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=autobarcode 2. Set to "generated in the form 1, 2, 3" 3. Go to http://localhost:8081/cgi-bin/koha/cataloguing/additem.pl?biblionumber=1#additema&searchid=scs_1607059974968 4. Add item with barcode 978e0143019375 5. Click "p - Barcode" 6. Note the barcode is "Inf" After applying patch: 1. Go to http://localhost:8081/cgi-bin/koha/cataloguing/additem.pl?biblionumber=1#additema&searchid=scs_1607059974968 2. Click "p - Barcode" 3. Note the barcode is "39999000019194" Signed-off-by: Marjorie <marjorie.barry-vila@collecto.ca> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 Marjorie Barry-Vila <marjorie.barry-vila@collecto.ca> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Failed QA |Signed Off --- Comment #15 from Marjorie Barry-Vila <marjorie.barry-vila@collecto.ca> --- Hi, I tested on sandbox https://sandbox.bywatersolutions.com/signoff/bz26328 and for me test plan worked well. Regards Marjorie -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 Jonathan Druart <jonathan.druart+koha@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart+koha@gmail. | |com --- Comment #16 from Jonathan Druart <jonathan.druart+koha@gmail.com> --- Hey, you forgot the tests! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 Jonathan Druart <jonathan.druart+koha@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 Jonathan Druart <jonathan.druart+koha@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #131592|0 |1 is obsolete| | --- Comment #17 from Jonathan Druart <jonathan.druart+koha@gmail.com> --- Created attachment 131976 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=131976&action=edit Bug 26328: Cast barcode from varchar to integer for incremental barcode Without this patch, the incremental barcode generation will treat 978e0143019375 as having an exponent and interpret it as a very large number. With this patch, the incremental barcode generation will first cast barcode varchar strings to integers before finding a max() value. In this case 978e0143019375 becomes 978 instead of 1.7976931348623157e308 Test plan: 0. Using koha-testing-docker Before applying patch: 1. Go to http://localhost:8081/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=autobarcode 2. Set to "generated in the form 1, 2, 3" 3. Go to http://localhost:8081/cgi-bin/koha/cataloguing/additem.pl?biblionumber=1#additema&searchid=scs_1607059974968 4. Add item with barcode 978e0143019375 5. Click "p - Barcode" 6. Note the barcode is "Inf" After applying patch: 1. Go to http://localhost:8081/cgi-bin/koha/cataloguing/additem.pl?biblionumber=1#additema&searchid=scs_1607059974968 2. Click "p - Barcode" 3. Note the barcode is "39999000019194" Signed-off-by: Marjorie <marjorie.barry-vila@collecto.ca> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 --- Comment #18 from Jonathan Druart <jonathan.druart+koha@gmail.com> --- Created attachment 131977 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=131977&action=edit Bug 26328: Add test Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)| |22.05.00 released in| | Status|Passed QA |Pushed to master -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 --- Comment #19 from Fridolin Somers <fridolin.somers@biblibre.com> --- Pushed to master for 22.05, thanks to everybody involved 🦄 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)|22.05.00 |22.05.00,21.11.05 released in| | Status|Pushed to master |Pushed to stable CC| |kyle@bywatersolutions.com --- Comment #20 from Kyle M Hall <kyle@bywatersolutions.com> --- Pushed to 21.11.x for 21.11.05 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrew@bywatersolutions.com Version(s)|22.05.00,21.11.05 |22.05.00,21.11.05,21.05.14 released in| | Status|Pushed to stable |Pushed to oldstable --- Comment #21 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- Pushed to 21.05.x for 21.05.14 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26328 Victor Grousset/tuxayo <victor@tuxayo.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)|22.05.00,21.11.05,21.05.14 |22.05.00,21.11.05,21.05.14, released in| |20.11.18 Resolution|--- |FIXED Status|Pushed to oldstable |RESOLVED CC| |victor@tuxayo.net --- Comment #22 from Victor Grousset/tuxayo <victor@tuxayo.net> --- Backported: Pushed to 20.11.x branch for 20.11.18 -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org