It will be handy to have an OO method to generate a MARC::Field object out of a Koha::Item object. All the required data is in place and it could aid in performance as well.
Created attachment 94029 [details] [review] Bug 23807: Add Koha::Item->as_marc_field
This is a POC. It uses the default FW when it shouldn't, as each FW might have a different mapping for items.itemnumber.
(In reply to Tomás Cohen Arazi from comment #2) > This is a POC. It uses the default FW when it shouldn't, as each FW might > have a different mapping for items.itemnumber. Well, not POC. It is completely funcional and the default framework is a reasonable fallback. I will try to submit the unit tests, but please consider testing it along with the filter on the performance patchsets.
(In reply to Tomás Cohen Arazi from comment #3) > (In reply to Tomás Cohen Arazi from comment #2) > > This is a POC. It uses the default FW when it shouldn't, as each FW might > > have a different mapping for items.itemnumber. > > Well, not POC. It is completely funcional and the default framework is a > reasonable fallback. I will try to submit the unit tests, but please > consider testing it along with the filter on the performance patchsets. I think not only a fallback, if I understand correctly, the default framework defines the mappings now: Bug 19096 - Koha to MARC mappings (Part 2): Make Default authoritative
Created attachment 94094 [details] [review] Bug 23807: Unit tests This patch introduces tests for the Koha::Item->as_marc_field method. It tries to cover all the use cases. To test: 1. Apply this patchset 2. Run: $ kshell k$ prove t/db_dependent/Koha/Item.t => SUCCESS; Tests pass! 3. Sign off :-D
Created attachment 94274 [details] [review] Bug 23807: Add Koha::Item->as_marc_field Signed-off-by: Jan Kolator <kolatorj@email.cz>
Created attachment 94275 [details] [review] Bug 23807: Unit tests This patch introduces tests for the Koha::Item->as_marc_field method. It tries to cover all the use cases. To test: 1. Apply this patchset 2. Run: $ kshell k$ prove t/db_dependent/Koha/Item.t => SUCCESS; Tests pass! 3. Sign off :-D Signed-off-by: Jan Kolator <kolatorj@email.cz>
Created attachment 94279 [details] [review] Bug 23807: Add Koha::Item->as_marc_field Signed-off-by: Jan Kolator <kolatorj@email.cz> Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Created attachment 94280 [details] [review] Bug 23807: Unit tests This patch introduces tests for the Koha::Item->as_marc_field method. It tries to cover all the use cases. To test: 1. Apply this patchset 2. Run: $ kshell k$ prove t/db_dependent/Koha/Item.t => SUCCESS; Tests pass! 3. Sign off :-D Signed-off-by: Jan Kolator <kolatorj@email.cz> Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Nice work! Pushed to master for 19.11.00
Any good reasons to have called GetMarcSubfieldStructure with the unsafe flag set? % grep unsafe t/db_dependent/Koha/Item.t my $mss = C4::Biblio::GetMarcSubfieldStructure( '', { unsafe => 1 } ); $mss = C4::Biblio::GetMarcSubfieldStructure( '', { unsafe => 0 } ); Unsafe from tests don't feel safe :) I am seeing some tests failing (when run twice) because of it.
I've opened bug 27007.