View | Details | Raw Unified | Return to bug 20886
Collapse All | Expand All

(-)a/Koha/Object.pm (-1 / +4 lines)
Lines 22-27 use Modern::Perl; Link Here
22
22
23
use Carp;
23
use Carp;
24
use Mojo::JSON;
24
use Mojo::JSON;
25
use Scalar::Util qw( looks_like_number );
25
use Try::Tiny;
26
use Try::Tiny;
26
27
27
use Koha::Database;
28
use Koha::Database;
Lines 241-247 sub TO_JSON { Link Here
241
                ? Mojo::JSON->true
242
                ? Mojo::JSON->true
242
                : Mojo::JSON->false;
243
                : Mojo::JSON->false;
243
        }
244
        }
244
        elsif ( _numeric_column_type( $columns_info->{$col}->{data_type} ) ) {
245
        elsif ( _numeric_column_type( $columns_info->{$col}->{data_type} )
246
            and looks_like_number( $unblessed->{$col} )
247
        ) {
245
248
246
            # TODO: Remove once the solution for
249
            # TODO: Remove once the solution for
247
            # https://rt.cpan.org/Ticket/Display.html?id=119904
250
            # https://rt.cpan.org/Ticket/Display.html?id=119904
(-)a/t/db_dependent/Koha/Object.t (-2 / +4 lines)
Lines 161-167 subtest 'discard_changes' => sub { Link Here
161
161
162
subtest 'TO_JSON tests' => sub {
162
subtest 'TO_JSON tests' => sub {
163
163
164
    plan tests => 7;
164
    plan tests => 8;
165
165
166
    $schema->storage->txn_begin;
166
    $schema->storage->txn_begin;
167
167
Lines 169-174 subtest 'TO_JSON tests' => sub { Link Here
169
    my $borrowernumber = $builder->build(
169
    my $borrowernumber = $builder->build(
170
        { source => 'Borrower',
170
        { source => 'Borrower',
171
          value => { lost => 1,
171
          value => { lost => 1,
172
                     sms_provider_id => undef,
172
                     gonenoaddress => 0,
173
                     gonenoaddress => 0,
173
                     updated_on => $dt,
174
                     updated_on => $dt,
174
                     lastseen   => $dt, } })->{borrowernumber};
175
                     lastseen   => $dt, } })->{borrowernumber};
Lines 185-190 subtest 'TO_JSON tests' => sub { Link Here
185
    ok( $gonenoaddress->isa('JSON::PP::Boolean'), 'Boolean attribute type is correct' );
186
    ok( $gonenoaddress->isa('JSON::PP::Boolean'), 'Boolean attribute type is correct' );
186
    is( $gonenoaddress, 0, 'Boolean attribute value is correct (false)' );
187
    is( $gonenoaddress, 0, 'Boolean attribute value is correct (false)' );
187
188
189
    is( $patron->TO_JSON->{sms_provider_id}, undef, 'Undef values should not be casted to 0' );
190
188
    ok( !isvstring($patron->borrowernumber), 'Integer values are not coded as strings' );
191
    ok( !isvstring($patron->borrowernumber), 'Integer values are not coded as strings' );
189
192
190
    my $rfc3999_regex = qr/
193
    my $rfc3999_regex = qr/
191
- 

Return to bug 20886