Bugzilla – Attachment 105597 Details for
Bug 25638
API related tests failing on comparing floats
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25638: Fix float/decimal comparison in API related tests
Bug-25638-Fix-floatdecimal-comparison-in-API-relat.patch (text/plain), 2.29 KB, created by
Tomás Cohen Arazi (tcohen)
on 2020-06-05 18:56:18 UTC
(
hide
)
Description:
Bug 25638: Fix float/decimal comparison in API related tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2020-06-05 18:56:18 UTC
Size:
2.29 KB
patch
obsolete
>From 7afc798c38984b2eb4837d6d601ff15b6e3e0746 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 2 Jun 2020 14:40:04 +0200 >Subject: [PATCH] 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> >--- > Koha/Object.pm | 23 ++++++++++++++++++++++- > 1 file changed, 22 insertions(+), 1 deletion(-) > >diff --git a/Koha/Object.pm b/Koha/Object.pm >index ed7cc4bdc9b..6a741400be7 100644 >--- a/Koha/Object.pm >+++ b/Koha/Object.pm >@@ -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 >-- >2.27.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 25638
:
105484
|
105485
|
105582
|
105583
|
105590
|
105595
|
105596
| 105597 |
105598
|
105599
|
105665