[Bug 43880] New: REST API: like search on a boolean column matches every true row
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43880 Bug ID: 43880 Summary: REST API: like search on a boolean column matches every true row Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: REST API Assignee: koha-bugs@lists.koha-community.org Reporter: martin.renvoize@openfifth.co.uk QA Contact: tomascohen@gmail.com CC: tomascohen@gmail.com Target Milestone: --- The REST API turns a pattern on a boolean column into a plain true value, so a "like" search on such a column matches every row where the column is true. Koha::Object::_recursive_fixup coerces any value on an is_boolean column with ($value ? 1 : 0). It recurses into hashes, so { like => '%foo%' } becomes { like => 1 } and the query becomes active LIKE 1, which is true for every active row. This is visible in the vendors table (Acquisitions > Vendors): the global search ORs a LIKE across every searchable column, including the boolean active column, so searching for a vendor name also lists every active vendor. It also makes t/cypress/integration/Acquisitions/Vendors_spec.ts ("receive should open in the same tab") depend on the order of leftover vendors: it clicks tr:first, which is whichever active vendor sorts first rather than the one it created. It failed on the Debian 12 Jenkins runs for that reason. Test plan: 1. Apply the tests patch only (or run it before the fix) and run prove t/db_dependent/api/v1/acquisitions_vendors.t => the new subtest fails 2. Apply the fix and run it again => it passes 3. In the staff interface go to Acquisitions > Vendors with at least two active vendors and search for a name that only one has => only that vendor is listed 4. Run t/cypress/integration/Acquisitions/Vendors_spec.ts => passes -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43880 --- Comment #1 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 208640 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208640&action=edit Bug 43880: Add tests for like search on a boolean column Searching the vendors list with a pattern also matches the boolean active column, listing every active vendor. Test plan: 1. Run prove t/db_dependent/api/v1/acquisitions_vendors.t => FAIL: the like pattern on active is treated as true Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43880 --- Comment #2 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 208641 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208641&action=edit Bug 43880: Do not coerce like patterns on boolean columns _recursive_fixup turned { like => '%foo%' } on an is_boolean column into { like => 1 }, so the query matched every row where the column is true. Leave pattern operators (like, not_like, regexp) untouched. Test plan: 1. Run prove t/db_dependent/api/v1/acquisitions_vendors.t => SUCCESS: Tests pass 2. Search the vendors table for a name only one active vendor has => Only that vendor is listed 3. Run t/cypress/integration/Acquisitions/Vendors_spec.ts => SUCCESS Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43880 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43880 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #208640|0 |1 is obsolete| | Attachment #208641|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43880 --- Comment #3 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 208643 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208643&action=edit Bug 43880: Add tests for like search on a boolean column Searching the vendors list with a pattern also matches the boolean active column, listing every active vendor. Test plan: 1. Run prove t/db_dependent/api/v1/acquisitions_vendors.t => FAIL: the like pattern on active is treated as true Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43880 --- Comment #4 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 208644 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208644&action=edit Bug 43880: Do not coerce like patterns on boolean columns _recursive_fixup turned { like => '%foo%' } on an is_boolean column into { like => 1 }, so the query matched every row where the column is true. Leave pattern operators (like, not_like, regexp) untouched. Test plan: 1. Run prove t/db_dependent/api/v1/acquisitions_vendors.t => SUCCESS: Tests pass 2. Search the vendors table for a name only one active vendor has => Only that vendor is listed 3. Run t/cypress/integration/Acquisitions/Vendors_spec.ts => SUCCESS Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43880 --- Comment #5 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 208645 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208645&action=edit Bug 43880: Select the vendor row by name in Vendors_spec.ts The test clicked the first row of the filtered table, which depends on which other vendors exist. Look the row up by the vendor name instead. Test plan: 1. Run t/cypress/integration/Acquisitions/Vendors_spec.ts => SUCCESS, also with other vendors present Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43880 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |martin.renvoize@openfifth.c |ity.org |o.uk -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43880 --- Comment #6 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- The Cypress change has moved to its own bug, Bug 43881, so it can go through independently of this API fix. Obsoleting it here. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43880 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #208645|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43880 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43880 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #208643|0 |1 is obsolete| | Attachment #208644|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43880 --- Comment #7 from David Nind <david@davidnind.com> --- Created attachment 208743 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208743&action=edit Bug 43880: Add tests for like search on a boolean column Searching the vendors list with a pattern also matches the boolean active column, listing every active vendor. Test plan: 1. Run prove t/db_dependent/api/v1/acquisitions_vendors.t => FAIL: the like pattern on active is treated as true Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43880 --- Comment #8 from David Nind <david@davidnind.com> --- Created attachment 208744 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208744&action=edit Bug 43880: Do not coerce like patterns on boolean columns _recursive_fixup turned { like => '%foo%' } on an is_boolean column into { like => 1 }, so the query matched every row where the column is true. Leave pattern operators (like, not_like, regexp) untouched. Test plan: 1. Run prove t/db_dependent/api/v1/acquisitions_vendors.t => SUCCESS: Tests pass 2. Search the vendors table for a name only one active vendor has => Only that vendor is listed 3. Run t/cypress/integration/Acquisitions/Vendors_spec.ts => SUCCESS Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43880 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |david@davidnind.com --- Comment #9 from David Nind <david@davidnind.com> --- Testing notes (using KTD): 1. Test searching the vendors result table using the DataTable search (not the vendor search in the header). 2. I add additional vendors: - Another Vendor - Bad Company - Test 3. Before the patch, the table search did not work - all vendor entries were shown when you search (for example, vendor returns all vendors, not just the two with vendors in the name. 4. After the patch, the table search works as expected. -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org