[Dbix-class] Re: Possible error in DBIx::Class::TimeStamp

Oleg Kostyuk cub.uanic at gmail.com
Wed Aug 5 15:40:12 GMT 2009


Any thoughts?

2009/7/31 Oleg Kostyuk <cub.uanic at gmail.com>:
> Hello guys,
>
> I'm look at this part of DBIx/Class/TimeStamp.pm :
>
> =====  cut =====
> sub add_columns {
>   my ($self, @cols) = @_;
>   my @columns;
>
>   while (my $col = shift @cols) {
>       my $info = ref $cols[0] ? shift @cols : {};
>
>       if ( delete $info->{set_on_create} ) {
>           $info->{dynamic_default_on_create} = 'get_timestamp';
>       }
>
>       if ( delete $info->{set_on_update} ) {
>           $info->{dynamic_default_on_update} = 'get_timestamp';  # !!! (1)
>
>           if ( defined $info->{dynamic_default_on_create} and
>                $info->{dynamic_default_on_create} eq 'get_timestamp'
>            ) {
>               $info->{dynamic_default_on_update} = 'get_timestamp'; # !!!
> (2)
>           }
>       }
>
>       push @columns, $col => $info;
>   }
>
>   return $self->next::method(@columns);
> }
> =====  cut =====
>
> And can't understood, why we need (2), if we already did exactly same thing
> in (1) ?
> May be, there is some error?
>
>
> As for me, following code have more sence:
>
> =====  cut =====
>       if ( delete $info->{set_on_update} ) {
>           $info->{dynamic_default_on_update} = 'get_timestamp';
>
>           unless ( defined $info->{dynamic_default_on_create} and
>                $info->{dynamic_default_on_create} eq 'get_timestamp'
>            ) {
>               $info->{dynamic_default_on_create} = 'get_timestamp';
>           }
>       }
> =====  cut =====
>
>
> I'm using:
>
> % pmvers DBIx::Class
> 0.08108
>
> Could anyone explain me, what going on here?
> Thanks in advance.
>


-- 
Sincerely yours,
Oleg Kostyuk (CUB-UANIC)



More information about the DBIx-Class mailing list