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

(-)a/Koha/Object.pm (-1 / +6 lines)
Lines 545-551 sub attributes_from_api { Link Here
545
          ? $from_api_mapping->{$key}
545
          ? $from_api_mapping->{$key}
546
          : $key;
546
          : $key;
547
547
548
        if ( _date_or_datetime_column_type( $columns_info->{$koha_field_name}->{data_type} ) ) {
548
        if ( $columns_info->{$koha_field_name}->{is_boolean} ) {
549
            # TODO: Remove when D8 is formally deprecated
550
            # Handle booleans gracefully
551
            $value = ( $value ) ? 1 : 0;
552
        }
553
        elsif ( _date_or_datetime_column_type( $columns_info->{$koha_field_name}->{data_type} ) ) {
549
            try {
554
            try {
550
                $value = dt_from_string($value, 'rfc3339');
555
                $value = dt_from_string($value, 'rfc3339');
551
            }
556
            }
(-)a/t/db_dependent/Koha/Object.t (-5 / +15 lines)
Lines 455-469 subtest 'new_from_api() tests' => sub { Link Here
455
455
456
subtest 'attributes_from_api() tests' => sub {
456
subtest 'attributes_from_api() tests' => sub {
457
457
458
    plan tests => 8;
458
    plan tests => 12;
459
459
460
    my $patron = Koha::Patron->new();
460
    my $patron = Koha::Patron->new();
461
461
462
    use Data::Printer colored => 1;
463
464
    my $attrs = $patron->attributes_from_api(
462
    my $attrs = $patron->attributes_from_api(
465
        {
463
        {
466
            updated_on  => '2019-12-27T14:53:00'
464
            updated_on => '2019-12-27T14:53:00',
467
        }
465
        }
468
    );
466
    );
469
467
Lines 519-524 subtest 'attributes_from_api() tests' => sub { Link Here
519
        'date_of_birth',
517
        'date_of_birth',
520
        'Exception parameter is the API field name, not the DB one'
518
        'Exception parameter is the API field name, not the DB one'
521
    );
519
    );
520
521
    # Booleans
522
    $attrs = $patron->attributes_from_api(
523
        {
524
            incorrect_address => Mojo::JSON->true,
525
            patron_card_lost  => Mojo::JSON->false,
526
        }
527
    );
528
529
    ok( exists $attrs->{gonenoaddress}, 'Attribute gets translated' );
530
    is( $attrs->{gonenoaddress}, 1, 'Boolean correctly translated to integer (true => 1)' );
531
    ok( exists $attrs->{lost}, 'Attribute gets translated' );
532
    is( $attrs->{lost}, 0, 'Boolean correctly translated to integer (false => 0)' );
522
};
533
};
523
534
524
subtest "Test update method" => sub {
535
subtest "Test update method" => sub {
525
- 

Return to bug 23893