Bug 19277: TT syntax - Display ordered data
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 8 Sep 2017 12:38:28 +0000 (09:38 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 12 Sep 2017 14:29:11 +0000 (11:29 -0300)
commit5a64723e6d3d21b3e0d9302b273b6fbb43c969af
tree0445e1577dd0536036747ed5e8caad82aaeffa90
parent0ed469525fe16e36663c1f5266568beb5e27672d
Bug 19277: TT syntax - Display ordered data

This issue has been highlighted by a failing test: ISSUESLIP displays checkouts in random order

I thought it was because of dates comparison, but it comes from the following line in C4::Letters::_get_tt_params
  my $objects = $module->search( { $key => { -in => $values } } );

The DBMS will return data like there is ordered in the DB.
For instance:
  select borrowernumber from borrowers where borrowernumber in (5, 3, 1);
or
  select borrowernumber from borrowers where borrowernumber=5 or borrowernumber=3 or borrowernumber=1;

will return 1, 3, 5

I did not find a generic way to do that, so used "ORDER BY FIELD" which will not be portable.

Test plan:
If you do not apply this patch, the tests will sometime fail

Signed-off-by: Lee Jamison <ldjamison@marywood.edu>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
C4/Letters.pm