]> git.koha-community.org Git - koha.git/commit
Bug 9770: fix sorting of Dewey call numbers that contain prefixes
authorJason Etheridge <jason@esilibrary.com>
Fri, 8 Mar 2013 15:41:06 +0000 (10:41 -0500)
committerChris Hall <followingthepath@gmail.com>
Tue, 20 Aug 2013 09:15:45 +0000 (21:15 +1200)
commite311ea1308fd05bbdbbf2d95bb1fac8ba6245b7d
treeba8faeda44be3b6771aa8f3fcbde4711ca3bcada
parent1254f88b25700408492edea9cbacdea5e52c913b
Bug 9770: fix sorting of Dewey call numbers that contain prefixes

C4::ClassSortRoutine::Dewey can pad the wrong part of a call number internally.

The subroutine get_class_sort_key tokenizes a call number string (splitting on
periods and whitespace) and counts the number of tokens that solely contain
digits.  If there is only one such digit group, a comment in the code states
that it will pad said digit group.  However, the bug is that the code assumes
said digit group is the first token, when this may not be the case.

In practice, this can cause poor sorting when used a call number is in the form
of PREFIX _space_ 3DIGITS.

To test:

[1] Create two item records whose class scheme is set to
    'ddc' (Dewey) and whose call numbers contain prefixes, e.g.,
    J DVD 700.1 ABC and J DVD 850 DEF.
[2] Use the inventory tool to produce a list of item items that include
    the two created in step 1.  Obsere that that items are sorted
    in the incorrect order, with "J DVD 850 DEF" coming before
    "J DVD 700.1 ABC".  Alternatively, run the following SQL
    to see the incorrect sort order:

    SELECT cn_sort, itemcallnumber
    FROM items
    WHERE itemcallnumber LIKE 'J DVD%'
    ORDER BY cn_sort;

[4] Apply this patch.
[5] Run misc/maintenance/touch_all_items.pl to force cn_sort to be
    recalculated.
[6] Repeat step 2 and verify that the call numbers are now sorted
    corrected.

Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit dba36a7a1216238a260ea5fbe2218627487e9f19)
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
(cherry picked from commit f05642589d94c25ef1b1f01b4a2606fe455400b8)
Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
(cherry picked from commit f05642589d94c25ef1b1f01b4a2606fe455400b8)
Signed-off-by: Chris Hall <followingthepath@gmail.com>
(cherry picked from commit 404a931efa9365ae084f088111382eb2076a0a7e)
C4/ClassSortRoutine/Dewey.pm