[Koha-bugs] [Bug 19686] objects.search helper needs a to_model param

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Dec 1 22:56:21 CET 2017


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

David Bourgault <david.bourgault at inlibro.com> changed:

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

--- Comment #7 from David Bourgault <david.bourgault at inlibro.com> ---
Created attachment 69464
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69464&action=edit
Bug 19686: Add objects.search a 'to_model' param

This patch introduces a new parameter to the objects.search Mojo helper.
The idea behind this, is that if there's any attribute name mapping
between the DB objects and the API exposed ones, we should be able to
pass it to objects.search so the filtering query params are mapped
correctly for building the DBIC query, like this example:

  my $patrons_set = Koha::Patrons->new;
  my @patrons = $c->objects->search( $patrons_set,
                                     \&to_model
                                    )->as_list;
  # and probably
  @patrons = map {to_api($_)} @patrons;

The to_model function needs to avoid autovivification, to prevent
messing with the query parameters (undef params).

To test:
- Apply this patches
- Run:
  $ kshell
 k$ prove t/db_dependent/Koha/REST/Plugin/Objects.t
=> SUCCESS: Tests pass! Params get mapped!
- Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen at theke.io>

Signed-off-by: David Bourgault <david.bourgault at inlibro.com>

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


More information about the Koha-bugs mailing list