Subject: | Problem with empty key columns |
Date: | Wed, 26 Oct 2011 13:58:28 +0200 |
To: | bug-Win32-InstallShield [...] rt.cpan.org |
From: | Torsten.Werner [...] assyst.de |
Hi James,
at first the environment to reproduce the bug:
OS: Win 7
Perl: This is perl, v5.10.1 built for MSWin32-x86-multi-thread
Version of Win32::InstallShield.pm: 0.6
Version of InstallShield: InstaaShield 2011 Hotfix A
InstallShield will create a table like the following during patch
creation:
<table name="MsiPatchMetadata">
<col key="yes" def="s72">PatchConfiguration_</col>
<col key="yes" def="S72">Company</col>
<col key="yes" def="s72">Property</col>
<col def="S0">Value</col>
<row><td>CADCAM 20.11.1
Patch</td><td></td><td>AllowRemoval</td><td>1</td></row>
<row><td>CADCAM 20.11.1
Patch</td><td></td><td>Classification</td><td>Patch</td></row>
<row><td>CADCAM 20.11.1
Patch</td><td></td><td>Description</td><td>Patch for assyst CADCAM
20.11.1</td></row>
<row><td>CADCAM 20.11.1
Patch</td><td></td><td>DisplayName</td><td>CADCAM 20.11.1 Patch
9</td></row>
<row><td>CADCAM 20.11.1
Patch</td><td></td><td>ManufacturerName</td><td>assyst GmbH</td></row>
<row><td>CADCAM 20.11.1
Patch</td><td></td><td>MoreInfoURL</td><td>www.assyst.de</td></row>
<row><td>CADCAM 20.11.1
Patch</td><td></td><td>TargetProductName</td><td>CADCAM</td></row>
</table>
There is a key column "Company" defined which is empty.
The parser will return a undefined value for this column.
During update is the function _build_key involved:
sub _build_key {
my ($self, $table, $values) = @_;
my $p = $self->_parsed($table);
my $lookup_key = '';
# build the lookup key by concatenating the key columns
foreach my $i (0..$#{$p->{'columns'}}) {
if($p->{'columns'}[$i]{'is_key'}) {
my $width = $p->{'columns'}[$i]{'width'};
if(defined($values->[$i])) {
$lookup_key .= sprintf("%-${width}s",
$values->[$i]);
} else {
carp("Missing key column " .
$p->{'columns'}[$i]{'name'});
return;
}
}
}
return $lookup_key;
}
The function will call carp when the value is undef.
I did the following change (without check for side effects):
sub _build_key {
my ($self, $table, $values) = @_;
my $p = $self->_parsed($table);
my $lookup_key = '';
# build the lookup key by concatenating the key columns
foreach my $i (0..$#{$p->{'columns'}}) {
if($p->{'columns'}[$i]{'is_key'}) {
my $width = $p->{'columns'}[$i]{'width'};
$lookup_key .= sprintf("%-${width}s",
$values->[$i]//"");
}
}
return $lookup_key;
}
There is no check for the perl version in the module. The given fix works
with the new "//" operator (new in 5.8 or 5.10 I think).
Bye
Torsten
----------------------------------------------------------------------
assyst GmbH
Dr. Ing. Torsten Werner
Product Manager plan.assyst
Max-Planck-Str. 3
85609 Aschheim-Dornach
Germany
Phone: +49 (0)89 90505-0
Fax: +49 (0)89 90505-271
E-Mail: torsten.werner@assyst.de
Internet: http://www.assyst.de
Geschäftsführer: Dr. Andreas Seidl
Eingetragen beim Registergericht München HRB 180174
Sitz der Gesellschaft: 85609 Aschheim-Dornach
----------------------------------------------------------------------