[ic] Redundant code in DBI.pm?

Mike Heins mikeh at perusion.com
Fri Mar 13 13:57:39 UTC 2015


Quoting Peter (peter at pajamian.dhs.org):
> On 03/14/2015 01:58 AM, Mike Heins wrote:
> >>>>   for (my $i = 0;  $i < @$columns;  $i++) {
> >>>>       $cols[$i] = $$columns[$i];
> >>>> #::logDebug("checking column '$cols[$i]'");
> >>>>               if(defined $key) {
> >>>>                       $keycol = $i if $cols[$i] eq $key;
> >>>>               }
> >>>>               if(defined $config->{COLUMN_DEF}->{$cols[$i]}) {
> >>>>                       $cols[$i] .= " " .
> >>>> $config->{COLUMN_DEF}->{$cols[$i]};
> >>>>               }
> >>>>               else {
> >>>>                       $cols[$i] .= " $def_type";
> >>>>               }
> >>>>               $$columns[$i] = $cols[$i];
> >>>>               $$columns[$i] =~ s/\s+.*//;
> >>>>   }
> >>
> >> The reason is that at you can define the type in the column
> >> label of the table, i.e.
> >>
> >> code	price decimal(12)	description varchar(200)	image
> 
> Oh, I see, it looks like the first of those two lines is still
> redundant, though.

No,  I don't think so. 

> I think if we were to remove the $$columns[$i] =
> $cols[$i] line and leave the next one in then the code would still work,
> the column type could be defined in the column and just the name would
> be left in @$columns.
> 
> > Just tested that out of curiosity:
> 
> Just to satisfy my own curiosity, can you comment out the $$columns[$i]
> = $cols[$i]; line and see if your test still works?
> 

It seems to, and it seems safe and logical. But I would hesitate to
modify it at this point unless you are going to remove the bug/feature
completely.

I would be for removing it if we did some sanity checks on the final
product, i.e. check $$columns[i] for some field-name-like value.

-- 
Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.765.253.4194  <mike at perusion.com>

Life isn't fair, but it's good. -- Regina Brett



More information about the interchange-users mailing list