Bug 26414

Summary: Unable to export Withdrawn status using CSV profile
Product: Koha Reporter: Caroline Cyr La Rose <caroline.cyr-la-rose>
Component: ToolsAssignee: Alexis Ripetti <alexis.ripetti>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: aleisha, alexis.ripetti, david, didier.gautheron, jonathan.druart, lucas, victor
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
This patch fixes the export of MARC records and the withdrawn status when using CSV profiles. Before this fix the full 952 field was exported, rather than just the withdrawn status.
Version(s) released in:
20.11.00, 20.05.05, 19.11.11
Circulation function:
Attachments: Bug 26414: Unable to export Withdrawn status using CSV profile
Bug 26414: Unable to export Withdrawn status using CSV profile
Bug 26414: Unable to export Withdrawn status using CSV profile
Bug 26414: Unable to export Withdrawn status using CSV profile
Bug 26414: Unable to export Withdrawn status using CSV profile
Bug 26414: Tidy the tests
Bug 26414: Tidy the tests

Description Caroline Cyr La Rose 2020-09-08 21:44:44 UTC
When using CSV profiles to export MARC records, it is impossible to export the withdrawn status. I suspect it is because withdrawn is in 952$0 and 0 is considered null rather than an actual 0.

To replicate:
1) Go to Tools > CSV profiles
2) Click on New CSV profile
3) Enter a profile name (ex. Simple record)
4) In the Profile MARC fields field enter the following (for MARC21)
245a|100a|952o|9520
5) Save your profile
6) Go to Search and search for something
7) Add a couple of things in your cart
8) Go to your cart
9) Click on Download and choose your CSV profile
10) Open the file and notice the 9520 column contains the whole of the 952 field and not just the withdrawn status

I tried with different ways to write the MARC fields, but 952$0 just never shows alone.
245a|100a|952o|Withdrawn=952$0
245a|100a|952o|952$0

Caroline
Comment 1 Alexis Ripetti 2020-09-11 20:45:28 UTC
Created attachment 109970 [details] [review]
Bug 26414: Unable to export Withdrawn status using CSV profile

When using CSV profiles to export MARC records, it is impossible to export the withdrawn status. I suspect it is because withdrawn is in 952$0 and 0 is considered null rather than an actual 0.

Test Plan :
1) Go to Tools > CSV profiles
2) Click on New CSV profile
3) Enter a profile name (ex. Simple record)
4) In the Profile MARC fields field enter the following (for MARC21)
245a|100a|952o|9520
5) Save your profile
6) Go to Search and search for something
7) Add a couple of things in your cart
8) Go to your cart
9) Click on Download and choose your CSV profile
10) Open the file and notice the 9520 column contains the whole of the 952 field and not just the withdrawn status
11) Apply patch
12) Redo steps 9) and 10)
Comment 2 Didier Gautheron 2020-09-13 10:05:14 UTC
hi

Why not just a plain
  my $subfieldtag = $2;

and removing the WIP comment with the previous line?

Regards
Didier
Comment 3 Katrin Fischer 2020-09-13 21:34:50 UTC
Hi Alexis, whenever you plan to work on a patch for a bug, please assign it to yourself using the Asignee field. I've fixed it :)
Comment 4 David Nind 2020-09-15 21:25:24 UTC
Created attachment 110132 [details] [review]
Bug 26414: Unable to export Withdrawn status using CSV profile

When using CSV profiles to export MARC records, it is impossible to export the withdrawn status. I suspect it is because withdrawn is in 952$0 and 0 is considered null rather than an actual 0.

Test Plan :
1) Go to Tools > CSV profiles
2) Click on New CSV profile
3) Enter a profile name (ex. Simple record)
4) In the Profile MARC fields field enter the following (for MARC21)
245a|100a|952o|9520
5) Save your profile
6) Go to Search and search for something
7) Add a couple of things in your cart
8) Go to your cart
9) Click on Download and choose your CSV profile
10) Open the file and notice the 9520 column contains the whole of the 952 field and not just the withdrawn status
11) Apply patch
12) Redo steps 9) and 10)

Signed-off-by: David Nind <david@davidnind.com>
Comment 5 Katrin Fischer 2020-09-15 21:49:14 UTC
Hi Alexis,

I believe the tests may need a bit more work to run on different installations:

Processing additional checks OK!
kohadev-koha@kohadevbox:/home/vagrant/kohaclone$ prove t/db_dependent/Record/marcrecord2csv.t
t/db_dependent/Record/marcrecord2csv.t .. 1/13 
#   Failed test 'normal way: headers retrieved from the DB'
#   at t/db_dependent/Record/marcrecord2csv.t line 53.
#          got: '"TITLE STATEMENT"|"SUBJECT ADDED ENTRY--TOPICAL TERM"
# "The art of computer programming,Donald E. Knuth.,0;The art of another title,Donald E. Knuth. II,1"|"Computer programming.,462;Computer algorithms.,499"
# '
#     expected: '"Mention du titre"|Vedette-matière--Sujet
# "The art of computer programming,Donald E. Knuth.,0;The art of another title,Donald E. Knuth. II,1"|"Computer programming.,462;Computer algorithms.,499"
# '
# Looks like you failed 1 test of 13.
t/db_dependent/Record/marcrecord2csv.t .. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/13 subtests
Comment 6 Alexis Ripetti 2020-09-21 18:08:53 UTC
Created attachment 110479 [details] [review]
Bug 26414: Unable to export Withdrawn status using CSV profile

When using CSV profiles to export MARC records, it is impossible to export the withdrawn status. I suspect it is because withdrawn is in 952$0 and 0 is considered null rather than an actual 0.

Test Plan :
1) Go to Tools > CSV profiles
2) Click on New CSV profile
3) Enter a profile name (ex. Simple record)
4) In the Profile MARC fields field enter the following (for MARC21)
245a|100a|952o|9520
5) Save your profile
6) Go to Search and search for something
7) Add a couple of things in your cart
8) Go to your cart
9) Click on Download and choose your CSV profile
10) Open the file and notice the 9520 column contains the whole of the 952 field and not just the withdrawn status
11) Apply patch
12) Redo steps 9) and 10)

Signed-off-by: David Nind <david@davidnind.com>
Comment 7 Alexis Ripetti 2020-09-21 18:09:38 UTC
(In reply to didier from comment #2)
> hi
> 
> Why not just a plain
>   my $subfieldtag = $2;
> 
> and removing the WIP comment with the previous line?
> 
> Regards
> Didier

Hi,
I fixed it.
Comment 8 Alexis Ripetti 2020-09-21 18:21:04 UTC
(In reply to Katrin Fischer from comment #5)
> Hi Alexis,
> 
> I believe the tests may need a bit more work to run on different
> installations:

Hi Katrin,
I reseted the test that I had changed.
The tests should now pass on your installation.
Comment 9 David Nind 2020-09-21 20:16:29 UTC
Created attachment 110492 [details] [review]
Bug 26414: Unable to export Withdrawn status using CSV profile

When using CSV profiles to export MARC records, it is impossible to export the withdrawn status. I suspect it is because withdrawn is in 952$0 and 0 is considered null rather than an actual 0.

Test Plan :
1) Go to Tools > CSV profiles
2) Click on New CSV profile
3) Enter a profile name (ex. Simple record)
4) In the Profile MARC fields field enter the following (for MARC21)
245a|100a|952o|9520
5) Save your profile
6) Go to Search and search for something
7) Add a couple of things in your cart
8) Go to your cart
9) Click on Download and choose your CSV profile
10) Open the file and notice the 9520 column contains the whole of the 952 field and not just the withdrawn status
11) Apply patch
12) Redo steps 9) and 10)

Signed-off-by: David Nind <david@davidnind.com>
Comment 10 Katrin Fischer 2020-09-21 21:17:12 UTC
Created attachment 110515 [details] [review]
Bug 26414: Unable to export Withdrawn status using CSV profile

When using CSV profiles to export MARC records, it is impossible to export the withdrawn status. I suspect it is because withdrawn is in 952$0 and 0 is considered null rather than an actual 0.

Test Plan :
1) Go to Tools > CSV profiles
2) Click on New CSV profile
3) Enter a profile name (ex. Simple record)
4) In the Profile MARC fields field enter the following (for MARC21)
245a|100a|952o|9520
5) Save your profile
6) Go to Search and search for something
7) Add a couple of things in your cart
8) Go to your cart
9) Click on Download and choose your CSV profile
10) Open the file and notice the 9520 column contains the whole of the 952 field and not just the withdrawn status
11) Apply patch
12) Redo steps 9) and 10)

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 11 Jonathan Druart 2020-09-28 13:33:25 UTC
Created attachment 110851 [details] [review]
Bug 26414: Tidy the tests
Comment 12 Jonathan Druart 2020-09-28 13:36:05 UTC
Created attachment 110852 [details] [review]
Bug 26414: Tidy the tests
Comment 13 Jonathan Druart 2020-09-28 14:11:57 UTC
Pushed to master for 20.11, thanks to everybody involved!
Comment 14 Jonathan Druart 2020-09-28 14:14:13 UTC
Congratulations for your first patch pushed, Alexis! :)
Comment 15 Lucas Gass (lukeg) 2020-10-20 14:00:48 UTC
backported to 20.05.x for 20.05.05
Comment 16 Aleisha Amohia 2020-10-27 03:58:47 UTC
backported to 19.11.x for 19.11.11
Comment 17 Victor Grousset/tuxayo 2020-10-29 16:55:11 UTC
Not backported to oldoldstable (19.05.x). Feel free to ask if it's needed.