Bug 17420 - record export fails when itemtype on biblio
Summary: record export fails when itemtype on biblio
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Tools (show other bugs)
Version: Main
Hardware: All All
: P5 - low major
Assignee: Fridolin Somers
QA Contact: Marcel de Rooy
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-10 14:45 UTC by Fridolin Somers
Modified: 2019-06-27 09:24 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 17420 - record export fails when itemtype on biblio (1.66 KB, patch)
2016-10-10 14:53 UTC, Fridolin Somers
Details | Diff | Splinter Review
Bug 17420 - record export fails when itemtype on biblio (1.64 KB, patch)
2016-10-10 14:54 UTC, Fridolin Somers
Details | Diff | Splinter Review
Bug 17420 - record export fails when itemtype on biblio - followup (1.12 KB, patch)
2016-11-07 15:16 UTC, Fridolin Somers
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 17420 - record export fails when itemtype on biblio (1.74 KB, patch)
2016-11-09 22:15 UTC, Bernardo Gonzalez Kriegel
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 17420 - record export fails when itemtype on biblio - followup (1.22 KB, patch)
2016-11-09 22:15 UTC, Bernardo Gonzalez Kriegel
Details | Diff | Splinter Review
Bug 17420 - record export fails when itemtype on biblio (1.82 KB, patch)
2016-11-11 07:28 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 17420 - record export fails when itemtype on biblio - followup (1.30 KB, patch)
2016-11-11 07:28 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Fridolin Somers 2016-10-10 14:45:12 UTC
In Tools, Export data, you can export with a filter on item type.
When item type is on biblio record, you get the error :
export.pl: DBIx::Class::ResultSet::next(): Unknown column 'biblioitems.itemtype' in 'where clause' at /home/koha/src/Koha/Objects.pm line 150

Looks like its because this code use to be a SQL Select and is now a DBIx call :
 export.pl: DBIx::Class::ResultSet::next(): Unknown column 'biblioitems.itemtype' in 'where clause' at /home/koha/src/Koha/Objects.pm line 150
Comment 1 Fridolin Somers 2016-10-10 14:53:34 UTC
Created attachment 56117 [details] [review]
Bug 17420 - record export fails when itemtype on biblio

In Tools, Export data, you can export with a filter on item type.
When item type is on biblio record, you get the error :
export.pl: DBIx::Class::ResultSet::next(): Unknown column 'biblioitems.itemtype' in 'where clause' at /home/koha/src/Koha/Objects.pm line 150

Looks like its because this code use to be a SQL Select and is now a DBIx call :
                          C4::Context->preference('item-level_itypes')
                            ? ( 'items.itype' => $itemtype )
                            : ( 'me.itemtype' => $itemtype )

This patch corrects by using "me.itemtype"

Test plan :
- Use syspref item-level_itypes = biblio record
- Go to Tools > Export data : /cgi-bin/koha/tools/export.pl
- Select an item type
- Click on "Export biblio records"
=> Without patch you get an empty file and error 500 in logs
=> With patch you get a correct export file
Comment 2 Fridolin Somers 2016-10-10 14:54:43 UTC
Created attachment 56118 [details] [review]
Bug 17420 - record export fails when itemtype on biblio

In Tools, Export data, you can export with a filter on item type.
When item type is on biblio record, you get the error :
export.pl: DBIx::Class::ResultSet::next(): Unknown column 'biblioitems.itemtype' in 'where clause' at /home/koha/src/Koha/Objects.pm line 150

Looks like its because this code use to be a SQL Select and is now a DBIx call :
                          C4::Context->preference('item-level_itypes')
                            ? ( 'items.itype' => $itemtype )
                            : ( 'me.itemtype' => $itemtype )

This patch corrects by using "me.itemtype"

Test plan :
- Use syspref item-level_itypes = biblio record
- Go to Tools > Export data : /cgi-bin/koha/tools/export.pl
- Select an item type
- Click on "Export biblio records"
=> Without patch you get an error 500
=> With patch you get a correct export file
Comment 3 Fridolin Somers 2016-10-11 07:56:06 UTC
Confirmed by Kyle,
Now with Koha::Object, writing a condition on the object itself must be called with "me.xxxx".
Comment 4 Séverine Queune 2016-10-11 15:57:00 UTC
Patch tested with a sandbox, by Séverine <severine.queune@bulac.fr>
Comment 5 Jonathan Druart 2016-10-25 09:30:05 UTC
You should also propose the same change for the misc/export_records.pl script.
Comment 6 Fridolin Somers 2016-11-07 15:16:38 UTC
Created attachment 57269 [details] [review]
Bug 17420 - record export fails when itemtype on biblio - followup

Same as previous patch for misc/export_records.pl.

Test plan :
- Use syspref item-level_itypes = biblio record
- Run misc/export_records.pl
=> Without patch you get an error : DBD::mysql::st execute failed: Unknown column 'biblioitems.itemtype' in 'where clause' ...
=> With patch you get a correct export file
Comment 7 Fridolin Somers 2016-11-07 15:18:10 UTC
(In reply to Jonathan Druart from comment #5)
> You should also propose the same change for the misc/export_records.pl
> script.

Indeed, I had not seen it
Comment 8 Bernardo Gonzalez Kriegel 2016-11-09 22:15:08 UTC
Created attachment 57405 [details] [review]
[SIGNED-OFF] Bug 17420 - record export fails when itemtype on biblio

In Tools, Export data, you can export with a filter on item type.
When item type is on biblio record, you get the error :
export.pl: DBIx::Class::ResultSet::next(): Unknown column 'biblioitems.itemtype' in 'where clause' at /home/koha/src/Koha/Objects.pm line 150

Looks like its because this code use to be a SQL Select and is now a DBIx call :
                          C4::Context->preference('item-level_itypes')
                            ? ( 'items.itype' => $itemtype )
                            : ( 'me.itemtype' => $itemtype )

This patch corrects by using "me.itemtype"

Test plan :
- Use syspref item-level_itypes = biblio record
- Go to Tools > Export data : /cgi-bin/koha/tools/export.pl
- Select an item type
- Click on "Export biblio records"
=> Without patch you get an error 500
=> With patch you get a correct export file

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Fix the issue, no errors.
Comment 9 Bernardo Gonzalez Kriegel 2016-11-09 22:15:15 UTC
Created attachment 57406 [details] [review]
[SIGNED-OFF] Bug 17420 - record export fails when itemtype on biblio - followup

Same as previous patch for misc/export_records.pl.

Test plan :
- Use syspref item-level_itypes = biblio record
- Run misc/export_records.pl
=> Without patch you get an error : DBD::mysql::st execute failed: Unknown column 'biblioitems.itemtype' in 'where clause' ...
=> With patch you get a correct export file

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Export Ok, no errors.
Comment 10 Marcel de Rooy 2016-11-11 07:28:16 UTC
Created attachment 57442 [details] [review]
Bug 17420 - record export fails when itemtype on biblio

In Tools, Export data, you can export with a filter on item type.
When item type is on biblio record, you get the error :
export.pl: DBIx::Class::ResultSet::next(): Unknown column 'biblioitems.itemtype' in 'where clause' at /home/koha/src/Koha/Objects.pm line 150

Looks like its because this code use to be a SQL Select and is now a DBIx call :
                          C4::Context->preference('item-level_itypes')
                            ? ( 'items.itype' => $itemtype )
                            : ( 'me.itemtype' => $itemtype )

This patch corrects by using "me.itemtype"

Test plan :
- Use syspref item-level_itypes = biblio record
- Go to Tools > Export data : /cgi-bin/koha/tools/export.pl
- Select an item type
- Click on "Export biblio records"
=> Without patch you get an error 500
=> With patch you get a correct export file

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Fix the issue, no errors.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 11 Marcel de Rooy 2016-11-11 07:28:20 UTC
Created attachment 57443 [details] [review]
Bug 17420 - record export fails when itemtype on biblio - followup

Same as previous patch for misc/export_records.pl.

Test plan :
- Use syspref item-level_itypes = biblio record
- Run misc/export_records.pl
=> Without patch you get an error : DBD::mysql::st execute failed: Unknown column 'biblioitems.itemtype' in 'where clause' ...
=> With patch you get a correct export file

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Export Ok, no errors.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 12 Kyle M Hall (khall) 2016-11-12 02:32:40 UTC
Pushed to master for 16.11, thanks Frido!
Comment 13 Julian Maurice 2016-11-30 12:20:41 UTC
Pushed to 3.22.x, will be in 3.22.13
Comment 14 Mason James 2016-12-14 12:03:26 UTC
Pushed to 16.05.x, for 16.05.06 release