[interchange] Do not substitute key for non-existing columns when QUOTE_IDENTIFIERS is set.
Peter Ajamian
interchange-cvs at icdevgroup.org
Tue Jun 28 11:04:20 UTC 2016
commit 268ab52616becc3f1c74f48bce97059742349910
Author: Peter Ajamian <peter at pajamian.dhs.org>
Date: Tue Jun 28 22:59:48 2016 +1200
Do not substitute key for non-existing columns when QUOTE_IDENTIFIERS is set.
There is a bug in get_slice and set_slice where the key column (or more
specifically the column at index 0) is substituted when QUOTE_IDENTIFIERS is
set. This fixes the bug to push through the quoted version of whatever is
passed instead (and will likely error out from the db transaction instead).
Erroring out here is much more appropriate than attempting to read or write
seemingly random garbage to/from the db.
lib/Vend/Table/DBI.pm | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/lib/Vend/Table/DBI.pm b/lib/Vend/Table/DBI.pm
index 25d5360..d3bc98b 100644
--- a/lib/Vend/Table/DBI.pm
+++ b/lib/Vend/Table/DBI.pm
@@ -1300,7 +1300,11 @@ sub get_slice {
$fary = [ @_ ];
}
- $fary = [map {$s->[$QNAME][$s->[$CONFIG]{COLUMN_INDEX}{lc $_}]} @$fary] if $s->[$CONFIG]{QUOTE_IDENTIFIERS};
+ $fary = [map {
+ defined $s->[$CONFIG]{COLUMN_INDEX}{lc $_} ?
+ $s->[$QNAME][$s->[$CONFIG]{COLUMN_INDEX}{lc $_}] :
+ $s->quote_identifier($_)
+ } @$fary] if $s->[$CONFIG]{QUOTE_IDENTIFIERS};
my $fstring = join ",", @$fary;
$sql = "SELECT $fstring from $s->[$QTABLE] WHERE $s->[$QKEY] = $tkey";
@@ -1391,7 +1395,11 @@ sub set_slice {
}
}
- $fary = [map {$s->[$QNAME][$s->[$CONFIG]{COLUMN_INDEX}{lc $_}]} @$fary] if $s->[$CONFIG]{QUOTE_IDENTIFIERS};
+ $fary = [map {
+ defined $s->[$CONFIG]{COLUMN_INDEX}{lc $_} ?
+ $s->[$QNAME][$s->[$CONFIG]{COLUMN_INDEX}{lc $_}] :
+ $s->quote_identifier($_)
+ } @$fary] if $s->[$CONFIG]{QUOTE_IDENTIFIERS};
$tkey = $s->quote($key, $s->[$KEY]) if defined $key;
#::logDebug("tkey now $tkey");
More information about the interchange-cvs
mailing list