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

(-)a/Koha/Object.pm (-7 / +8 lines)
Lines 129-152 sub store { Link Here
129
        # Integers
129
        # Integers
130
        if ( _numeric_column_type( $columns_info->{$col}->{data_type} ) ) {
130
        if ( _numeric_column_type( $columns_info->{$col}->{data_type} ) ) {
131
            # Has been passed but not a number, usually an empty string
131
            # Has been passed but not a number, usually an empty string
132
            if ( defined $self->$col and not looks_like_number( $self->$col ) ) {
132
            my $value = $self->_result()->get_column($col);
133
            if ( defined $value and not looks_like_number( $value ) ) {
133
                if ( $columns_info->{$col}->{is_nullable} ) {
134
                if ( $columns_info->{$col}->{is_nullable} ) {
134
                    # If nullable, default to null
135
                    # If nullable, default to null
135
                    $self->$col(undef);
136
                    $self->_result()->set_column($col => undef);
136
                } else {
137
                } else {
137
                    # If cannot be null, get the default value
138
                    # If cannot be null, get the default value
138
                    # What if cannot be null and does not have a default value? Possible?
139
                    # What if cannot be null and does not have a default value? Possible?
139
                    $self->$col($columns_info->{$col}->{default_value});
140
                    $self->_result()->set_column($col => $columns_info->{$col}->{default_value});
140
                }
141
                }
141
            }
142
            }
142
        }
143
        }
143
        elsif ( _date_or_datetime_column_type( $columns_info->{$col}->{data_type} ) ) {
144
        elsif ( _date_or_datetime_column_type( $columns_info->{$col}->{data_type} ) ) {
144
            # Set to null if an empty string (or == 0 but should not happen)
145
            # Set to null if an empty string (or == 0 but should not happen)
145
            if ( defined $self->$col and not $self->$col ) {
146
            my $value = $self->_result()->get_column($col);
147
            if ( defined $value and not $value ) {
146
                if ( $columns_info->{$col}->{is_nullable} ) {
148
                if ( $columns_info->{$col}->{is_nullable} ) {
147
                    $self->$col(undef);
149
                    $self->_result()->set_column($col => undef);
148
                } else {
150
                } else {
149
                    $self->$col($columns_info->{$col}->{default_value});
151
                    $self->_result()->set_column($col => $columns_info->{$col}->{default_value});
150
                }
152
                }
151
            }
153
            }
152
        }
154
        }
153
- 

Return to bug 24788