Bug 30626

Summary: DT REST API wrapper not building the filter query correctly
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Architecture, internals, and plumbingAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: kyle, martin.renvoize, severine.queune, tomascohen
Version: unspecified   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30063
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30576
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.05.00
Bug Depends on: 24561    
Bug Blocks: 30576    
Attachments: Bug 30626: DT REST API wrapper - Fix general search
Bug 30626: Fix test
Bug 30626: DT REST API wrapper - Fix general search
Bug 30626: Fix test
Bug 30626: (QA follow-up) Fix test plan
Bug 30626: DT REST API wrapper - Fix general search
Bug 30626: Fix test
Bug 30626: (QA follow-up) Fix test plan
Bug 30626: Don't generate the query if no term passed

Description Jonathan Druart 2022-04-27 10:32:06 UTC
The general search query is not built correctly.

Say you have a table with column filters, like the main patron search:
General filter: henry
Specific filter on the 'Name' column: h

The generated query will be (= are actually LIKE):
{ Column1="henry" AND Column3="henry", ...} AND { Column2="h" }

The first term does not contain the Column2 attribute.
Comment 1 Jonathan Druart 2022-04-27 10:34:58 UTC
Created attachment 134016 [details] [review]
Bug 30626: DT REST API wrapper - Fix general search

The general search query is not built correctly.

Say you have a table with column filters, like the main patron search:
General filter: henry
Specific filter on the 'Name' column: h

The generated query will be (= are actually LIKE):
{ Column1="henry" AND Column3="henry", ...} AND { Column2="h" }

The first term does not contain the Column2 attribute.
Comment 2 Jonathan Druart 2022-04-27 10:35:02 UTC
Created attachment 134017 [details] [review]
Bug 30626: Fix test
Comment 3 Jonathan Druart 2022-04-27 10:36:11 UTC
We will certainly want to backport this fix. Skip the changes to the selenium tests if it does not apply.
Comment 4 Martin Renvoize 2022-04-27 10:55:50 UTC
Created attachment 134055 [details] [review]
Bug 30626: DT REST API wrapper - Fix general search

The general search query is not built correctly.

Say you have a table with column filters, like the main patron search:
General filter: henry
Specific filter on the 'Name' column: h

The generated query will be (= are actually LIKE):
{ Column1="henry" AND Column3="henry", ...} AND { Column2="h" }

The first term does not contain the Column2 attribute.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 5 Martin Renvoize 2022-04-27 10:55:54 UTC
Created attachment 134056 [details] [review]
Bug 30626: Fix test

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 6 Martin Renvoize 2022-04-27 10:55:58 UTC
Created attachment 134057 [details] [review]
Bug 30626: (QA follow-up) Fix test plan
Comment 7 Martin Renvoize 2022-04-27 10:57:34 UTC
All works well for me in testing (I tried both with the unit test and manually testing with relevant data).

I can't entirely remember/work out why we had that line in there in the first place the way we did though.. :(.

Signing off
Comment 8 Jonathan Druart 2022-04-27 11:40:39 UTC
(In reply to Martin Renvoize from comment #6)
> Created attachment 134057 [details] [review] [review]
> Bug 30626: (QA follow-up) Fix test plan

We won't need that on top of bug 30576.
Comment 9 Katrin Fischer 2022-04-27 17:36:09 UTC
Could you provide a test plan for this one?
Comment 10 Jonathan Druart 2022-04-28 07:23:37 UTC
(In reply to Katrin Fischer from comment #9)
> Could you provide a test plan for this one?

Go to /cgi-bin/koha/members/members-home.pl
Click search without providing any terms
Search "henry" in the global DT search and "h" in the "Name" column filter
Comment 11 Nick Clemens 2022-04-28 10:05:08 UTC
Created attachment 134214 [details] [review]
Bug 30626: DT REST API wrapper - Fix general search

The general search query is not built correctly.

Say you have a table with column filters, like the main patron search:
General filter: henry
Specific filter on the 'Name' column: h

The generated query will be (= are actually LIKE):
{ Column1="henry" AND Column3="henry", ...} AND { Column2="h" }

The first term does not contain the Column2 attribute.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 12 Nick Clemens 2022-04-28 10:05:12 UTC
Created attachment 134215 [details] [review]
Bug 30626: Fix test

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 13 Nick Clemens 2022-04-28 10:05:17 UTC
Created attachment 134216 [details] [review]
Bug 30626: (QA follow-up) Fix test plan

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 14 Katrin Fischer 2022-04-28 11:36:16 UTC
Now Nick beat me to it :) Nick++
Comment 15 Jonathan Druart 2022-04-28 13:01:03 UTC
Created attachment 134252 [details] [review]
Bug 30626: Don't generate the query if no term passed
Comment 16 Jonathan Druart 2022-04-28 13:02:23 UTC
*** Bug 30643 has been marked as a duplicate of this bug. ***
Comment 17 Fridolin Somers 2022-04-28 20:51:00 UTC
Pushed to master for 22.05, thanks to everybody involved 🦄
Comment 18 Kyle M Hall 2022-05-06 17:51:08 UTC
Does not apply to 21.11.x, please rebase if needed.