Bug 25638: Fix float/decimal comparison in API related tests

The previous fix from bug 25513 does not work in all versions we are
supporting.

Let's hack the float/decimal columns in the same way we did for integer.

prove t/db_dependent/api/v1/acquisitions_vendors.t \
      t/db_dependent/api/v1/patrons_accounts.t \
      t/db_dependent/api/v1/acquisitions_orders.t

Note that there is another error on U20 for acquisitions_orders.t

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit 8dfbc46aa4)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2020-06-02 14:40:04 +02:00 committed by Lucas Gass
parent 72b8ca8023
commit 93c0e6863a
1 changed files with 22 additions and 1 deletions

View File

@ -362,6 +362,15 @@ sub TO_JSON {
# is ported to whatever distro we support by that time
$unblessed->{$col} += 0;
}
elsif ( _decimal_column_type( $columns_info->{$col}->{data_type} )
and looks_like_number( $unblessed->{$col} )
) {
# TODO: Remove once the solution for
# https://rt.cpan.org/Ticket/Display.html?id=119904
# is ported to whatever distro we support by that time
$unblessed->{$col} += 0.00;
}
elsif ( _datetime_column_type( $columns_info->{$col}->{data_type} ) ) {
eval {
return unless $unblessed->{$col};
@ -410,12 +419,24 @@ sub _numeric_column_type {
'mediumint',
'smallint',
'tinyint',
);
return ( grep { $column_type eq $_ } @numeric_types) ? 1 : 0;
}
sub _decimal_column_type {
# TODO: Remove once the solution for
# https://rt.cpan.org/Ticket/Display.html?id=119904
# is ported to whatever distro we support by that time
my ($column_type) = @_;
my @decimal_types = (
'decimal',
'double precision',
'float'
);
return ( grep { $column_type eq $_ } @numeric_types) ? 1 : 0;
return ( grep { $column_type eq $_ } @decimal_types) ? 1 : 0;
}
=head3 prefetch_whitelist