]> git.koha-community.org Git - koha.git/commit
Bug 30645: Consider multiple instances of extended_attributes in query params
authorPedro Amorim <pedro.amorim@ptfs-europe.com>
Thu, 30 Nov 2023 16:43:02 +0000 (15:43 -0100)
committerKatrin Fischer <katrin.fischer@bsz-bw.de>
Fri, 26 Apr 2024 06:52:47 +0000 (08:52 +0200)
commit0acf44927d1e7f1ba719aaeee2eaaa7b39620e03
treeb40428be12ca9372ec80250da4f1ee760639556a
parent07682a5a67a80d29dbf98bb7612ce1edaeee94eb
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@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Koha/REST/Plugin/Objects.pm
Koha/REST/Plugin/Query.pm