Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Avoid quoting $column in set_field().
Avoid modifying $column by quoting it in the middle of set_field().  This had
the unintended consequence that later changes to the code which tried to access
column settings were broken due to the need to use $column as a key.  We now
create $qcolumn which holds the quoted value instead.
  • Loading branch information
pajamian committed May 26, 2016
1 parent ef7dc05 commit 974896c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/Vend/Table/DBI.pm
Expand Up @@ -1873,6 +1873,10 @@ sub set_field {
return undef;
}

my $qcolumn = $column;
$qcolumn = $s->[$DBI]->quote_identifier($column)
if $s->[$CONFIG]{QUOTE_IDENTIFIERS};

my $lcfg;
if(
$s->[$CONFIG]->{LENGTH_EXCEPTION_DEFAULT}
Expand All @@ -1899,15 +1903,11 @@ sub set_field {
$extra = "$f = $f, ";
}

# Would have preferred that this was not invasive, eliminates possibility
# of accessing column configuration below this
$column = $s->[$DBI]->quote_identifier($column) if $s->[$CONFIG]{QUOTE_IDENTIFIERS};

my $q;
if(! $s->record_exists($rawkey)) {
if( $s->[$CONFIG]{AUTO_SEQUENCE} ) {
$key = 0 if ! $key;
$q = qq{INSERT INTO $s->[$QTABLE] ($s->[$QKEY], $column) VALUES (?,?)};
$q = qq{INSERT INTO $s->[$QTABLE] ($s->[$QKEY], $qcolumn) VALUES (?,?)};
}
else {
#::logDebug("creating key '$rawkey' in table $s->[$TABLE]");
Expand All @@ -1917,7 +1917,7 @@ sub set_field {

my @args;
if(!$q) {
$q = qq{update $s->[$QTABLE] SET $extra$column = ? where $s->[$QKEY] = ?};
$q = qq{update $s->[$QTABLE] SET $extra$qcolumn = ? where $s->[$QKEY] = ?};
@args = ($value, $key);
}
else {
Expand Down

0 comments on commit 974896c

Please sign in to comment.