[ic] Redundant code in DBI.pm?

Mike Heins mikeh at perusion.com
Fri Mar 13 12:07:20 UTC 2015


Quoting Jon Jensen (jon at endpoint.com):
> On Fri, 13 Mar 2015, Peter wrote:
> 
> >IRT this block of code in the create_sql function in DBI.pm:
> >
> >   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 last two lines of the loop look to be redundant to me.
> >$$columns[$i] already contains the column name, and $cols[$i] contain
> >the column definition which is the column name, followed by a space and
> >other stuff, so the last two names write $cols[$i] back to $$columns[$i]
> >then strip the space + other stuff off the end leaving just the column
> >name ... which is what was in $$columns[$i] to begin with?
> >
> >Can we scrap those two lines or is there something I'm missing?
> 
> I read it that way too.
> 
> However, to avoid getting caught by anything "tricky, tricky" I
> think you would want to put some heavy debugging in there before &
> after and test pretty extensively.
> 
> It would also be good to hear from Mike whether he remembers any
> obscure reason for this.

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

I don't think anyone has really ever used that, so it could
go away if we want it to.

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

Socialism -- ideas so good they have to be enforced at gunpoint.
-- unknown



More information about the interchange-users mailing list