[Koha-bugs] [Bug 30645] Generated DBIC query incorrect for api searches across joined extended attributes when several terms are passed

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Dec 8 19:23:21 CET 2023


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30645

David Nind <david at davidnind.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #159652|0                           |1
        is obsolete|                            |

--- Comment #13 from David Nind <david at davidnind.com> ---
Created attachment 159676
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=159676&action=edit
Bug 30645: Consider multiple instances of extended_attributes in query params

This will rewrite a query like:

{
    "-and":[
        [
            {
                "extended_attributes.value":{
                    "like":"abc%"
                },
                "extended_attributes.code":[
                    [
                        "arbitrary_attr_code",
                        "another_attr_code"
                    ]
                ]
            }
        ],
        [
            {
                "extended_attributes.value":{
                    "like":"123%"
                },
                "extended_attributes.code":[
                    [
                        "arbitrary_attr_code",
                        "another_attr_code"
                    ]
                ]
            }
        ]
    ]
}

To:

{
    "-and":[
        [
            {
                "extended_attributes.value":{
                    "like":"abc%"
                },
                "extended_attributes.code":[
                    [
                        "arbitrary_attr_code",
                        "another_attr_code"
                    ]
                ]
            }
        ],
        [
            {
                "extended_attributes_2.value":{
                    "like":"123%"
                },
                "extended_attributes_2.code":[
                    [
                        "arbitrary_attr_code",
                        "another_attr_code"
                    ]
                ]
            }
        ]
    ]
}

And it'll also add the number of required 'join' attributes to the query
attributes to match it.

Test plan (with Joubu's test patch applied), run:
prove t/db_dependent/selenium/patrons_search.t

Or

Test plan, k-t-d:
1) Create 2 patron attributes, visit:
/cgi-bin/koha/admin/patron-attr-types.pl
2) Name the first attribute 'test1' and the second attribute 'test2'
3) On both, tick the 'Searchable' and 'Search by default' checkboxes
4) Edit a koha borrower, example visit:
/cgi-bin/koha/members/memberentry.pl?op=modify&destination=circ&borrowernumber=51
5) Put '123' on the test1 attribute, and 'abc' on the test2 attribute
6) Visit the main patrons page:
/cgi-bin/koha/members/members-home.pl
7) On the first left side filter input called 'Search', type '123' and search.
Notice you get the patron result
8) Repeat step 7, but type 'abc' instead of '123'. Notice you get the patron
result
9) Now do the same search but type '123 abc'. Notice you do not get the patron
result.
10) Apply patch. Repeat test plan. Notice you get the patron result in step 9).

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

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list