Koha-clms/Koha/REST/Plugin
Tomás Cohen Arazi 450e6bf178
Bug 43241: Fix datetime/boolean conversion in q= queries with DBIC operators
_parse_dbic_query maps field names but did not convert values. When
datetime or boolean filters are nested inside DBIC operators (-and,
-or) in the q= parameter, attributes_from_api (which normally handles
the conversion via _recursive_fixup) cannot reach them because it only
iterates top-level keys.

This patch fixes the issue in two places:

1. _parse_dbic_query (Query.pm): When a key maps to a known column
   (on the primary table or a related object), call _recursive_fixup
   to convert RFC3339 timestamps to MySQL format and booleans to 0/1.
   Related object instances are cached on the result_set to avoid
   repeated prefetch_whitelist lookups during recursive parsing.

2. Objects.pm: Move attributes_from_api to process named query params
   before merging with q= params. This avoids double-processing since
   q= values are already fixed up by _parse_dbic_query.

Test plan:
1. Apply the regression tests from the previous commit
2. Run:
   $ prove t/Koha/REST/Plugin/Query.t
   $ prove t/db_dependent/Koha/REST/Plugin/Objects.t
=> FAIL: Tests fail!
3. Apply this patch
4. Repeat step 2
=> SUCCESS: Tests pass!
5. Sign off :-D

Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io>
Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
2026-08-28 16:36:36 +00:00
..
Auth Bug 37711: Add support for staff interface auto-register on IdP 2025-11-05 07:12:32 -07:00
Exceptions.pm Bug 41950: Make +count embeds sortable via SQL COUNT subqueries 2026-06-29 16:19:48 +00:00
Objects.pm Bug 43241: Fix datetime/boolean conversion in q= queries with DBIC operators 2026-08-28 16:36:36 +00:00
Pagination.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
PluginRoutes.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Query.pm Bug 43241: Fix datetime/boolean conversion in q= queries with DBIC operators 2026-08-28 16:36:36 +00:00
Responses.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00