Prune out a method call from db->dbh->quote_identifier.
This commit is contained in:
parent
b7b633bf19
commit
11ac13c349
12 changed files with 47 additions and 47 deletions
|
|
@ -254,7 +254,7 @@ sub getTreePaginator {
|
|||
|
||||
my $p = WebGUI::Paginator->new( $session, '', $rowsPerPage, 'pn', $currentPage );
|
||||
|
||||
my $orderBy = $session->db->dbh->quote_identifier( $orderByColumn ) . ' ' . $orderByDirection;
|
||||
my $orderBy = $session->db->quote_identifier( $orderByColumn ) . ' ' . $orderByDirection;
|
||||
$p->setDataByArrayRef( $asset->getLineage( ['children'], { orderByClause => $orderBy } ) );
|
||||
|
||||
return $p;
|
||||
|
|
|
|||
|
|
@ -264,7 +264,7 @@ sub getAdjacentThread {
|
|||
my $sortCompareValue = $self->get($sortByField);
|
||||
|
||||
# make sortBy safe to include directly in SQL
|
||||
$sortBy = join('.', map { $session->db->dbh->quote_identifier($_) } split(/\./, $sortBy));
|
||||
$sortBy = join('.', map { $session->db->quote_identifier($_) } split(/\./, $sortBy));
|
||||
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session, 'nocreate');
|
||||
my $tagId = $versionTag ? $versionTag->getId : undef;
|
||||
|
|
|
|||
|
|
@ -356,7 +356,7 @@ Get a row of data from a thing. Returns a hashref
|
|||
|
||||
sub getThingRecord {
|
||||
my ( $self, $thingId, $recordId ) = @_;
|
||||
my $table = $self->session->db->dbh->quote_identifier( "Thingy_" . $thingId );
|
||||
my $table = $self->session->db->quote_identifier( "Thingy_" . $thingId );
|
||||
return $self->session->db->quickHashRef( "SELECT * FROM " . $table . " WHERE thingDataId=?", [$recordId] );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -112,11 +112,11 @@ sub copyCollateral {
|
|||
my $newId = $self->session->id->generate;
|
||||
|
||||
my $temp = $self->session->db->buildArrayRefOfHashRefs(
|
||||
"select * from ".$db->dbh->quote_identifier($table)." where ".$db->dbh->quote_identifier($keyName)."=".$db->quote($keyValue));
|
||||
"select * from ".$db->quote_identifier($table)." where ".$db->dbh->quote_identifier($keyName)."=".$db->quote($keyValue));
|
||||
my $hash = $temp->[0];
|
||||
$hash->{$keyName} = $newId;
|
||||
my @keys = keys %$hash;
|
||||
my $sql = "insert into ".$db->dbh->quote_identifier($table)
|
||||
my $sql = "insert into ".$db->quote_identifier($table)
|
||||
." (".join(',',map("`$_`",@keys)).") values(".join(',',map("?",@keys)).")";
|
||||
$self->session->db->write($sql,[map($hash->{$_},@keys)]);
|
||||
}
|
||||
|
|
@ -147,8 +147,8 @@ sub deleteCollateral {
|
|||
my $keyName = shift;
|
||||
my $keyValue = shift;
|
||||
my $db = $self->session->db;
|
||||
$self->session->db->write("delete from ".$db->dbh->quote_identifier($table)
|
||||
." where ".$db->dbh->quote_identifier($keyName)."=".$db->quote($keyValue));
|
||||
$self->session->db->write("delete from ".$db->quote_identifier($table)
|
||||
." where ".$db->quote_identifier($keyName)."=".$db->quote($keyValue));
|
||||
$self->updateHistory("deleted collateral item ".$keyName." ".$keyValue);
|
||||
}
|
||||
|
||||
|
|
@ -220,8 +220,8 @@ sub getCollateral {
|
|||
if ($keyValue eq "new" || $keyValue eq "") {
|
||||
return {$keyName=>"new"};
|
||||
} else {
|
||||
return $db->quickHashRef("select * from ".$db->dbh->quote_identifier($table)
|
||||
." where ".$db->dbh->quote_identifier($keyName)."=?",[$keyValue]);
|
||||
return $db->quickHashRef("select * from ".$db->quote_identifier($table)
|
||||
." where ".$db->quote_identifier($keyName)."=?",[$keyValue]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -453,13 +453,13 @@ sub setCollateral {
|
|||
|
||||
if ($properties->{$keyName} eq "new" || $properties->{$keyName} eq "") {
|
||||
$properties->{$keyName} = $self->session->id->generate();
|
||||
$sql = "insert into ".$db->dbh->quote_identifier($table)." (";
|
||||
$sql = "insert into ".$db->quote_identifier($table)." (";
|
||||
my $dbkeys = "";
|
||||
my $dbvalues = "";
|
||||
unless ($useSequence eq "0") {
|
||||
unless (exists $properties->{sequenceNumber}) {
|
||||
my ($seq) = $self->session->db->quickArray("select max(sequenceNumber) "
|
||||
." from ".$db->dbh->quote_identifier($table)." where $setName=?",[$setValue]);
|
||||
." from ".$db->quote_identifier($table)." where $setName=?",[$setValue]);
|
||||
$properties->{sequenceNumber} = $seq+1;
|
||||
}
|
||||
}
|
||||
|
|
@ -471,20 +471,20 @@ sub setCollateral {
|
|||
$dbkeys .= ',';
|
||||
$dbvalues .= ',';
|
||||
}
|
||||
$dbkeys .= $db->dbh->quote_identifier($key);
|
||||
$dbkeys .= $db->quote_identifier($key);
|
||||
$dbvalues .= $self->session->db->quote($properties->{$key});
|
||||
}
|
||||
$sql .= $dbkeys.') values ('.$dbvalues.')';
|
||||
$self->updateHistory("added collateral item ".$table." ".$properties->{$keyName});
|
||||
} else {
|
||||
$sql = "update ".$db->dbh->quote_identifier($table)." set ";
|
||||
$sql = "update ".$db->quote_identifier($table)." set ";
|
||||
foreach my $key (keys %{$properties}) {
|
||||
unless ($key eq "sequenceNumber" && $updateSequence ne "1") {
|
||||
$sql .= ',' if ($counter++ > 0);
|
||||
$sql .= $db->dbh->quote_identifier($key)."=".$db->quote($properties->{$key});
|
||||
$sql .= $db->quote_identifier($key)."=".$db->quote($properties->{$key});
|
||||
}
|
||||
}
|
||||
$sql .= " where ".$db->dbh->quote_identifier($keyName)."=".$db->quote($properties->{$keyName});
|
||||
$sql .= " where ".$db->quote_identifier($keyName)."=".$db->quote($properties->{$keyName});
|
||||
$self->updateHistory("edited collateral item ".$table." ".$properties->{$keyName});
|
||||
}
|
||||
$self->session->db->write($sql);
|
||||
|
|
|
|||
|
|
@ -199,10 +199,10 @@ sub secure_identifier {
|
|||
if(scalar(@parts) > 1) {
|
||||
my $table = $parts[0];
|
||||
my $column = $parts[1];
|
||||
$identifier = $db->dbh->quote_identifier($table).".".$db->dbh->quote_identifier($column);
|
||||
$identifier = $db->quote_identifier($table).".".$db->dbh->quote_identifier($column);
|
||||
}
|
||||
else {
|
||||
$identifier = $db->dbh->quote_identifier($identifier);
|
||||
$identifier = $db->quote_identifier($identifier);
|
||||
}
|
||||
|
||||
return $identifier;
|
||||
|
|
|
|||
|
|
@ -1201,7 +1201,7 @@ sub getThreadsPaginator {
|
|||
}
|
||||
$self->session->scratch->set($scratchSortOrder, $sortOrder);
|
||||
}
|
||||
$sortBy = join('.', map { $self->session->db->dbh->quote_identifier($_) } split(/\./, $sortBy));
|
||||
$sortBy = join('.', map { $self->session->db->quote_identifier($_) } split(/\./, $sortBy));
|
||||
$sortOrder ||= 'desc';
|
||||
|
||||
my $sql = "
|
||||
|
|
|
|||
|
|
@ -1330,7 +1330,7 @@ sub www_getAllSubmissions {
|
|||
$rules->{'joinClass' } = "WebGUI::Asset::EMSSubmission";
|
||||
$rules->{'whereClause' } = $whereClause;
|
||||
$rules->{'includeOnlyClasses'} = ['WebGUI::Asset::EMSSubmission'];
|
||||
$rules->{'orderByClause' } = $session->db->dbh->quote_identifier( $orderByColumn ) . ' ' . $orderByDirection if $orderByColumn;
|
||||
$rules->{'orderByClause' } = $session->db->quote_identifier( $orderByColumn ) . ' ' . $orderByDirection if $orderByColumn;
|
||||
|
||||
my $sql = "";
|
||||
|
||||
|
|
|
|||
|
|
@ -96,8 +96,8 @@ sub addField {
|
|||
my $thingyTableName = "Thingy_".$field->{thingId};
|
||||
my $columnName = "field_".$newFieldId;
|
||||
$db->write(
|
||||
"ALTER TABLE ".$db->dbh->quote_identifier($thingyTableName)
|
||||
." ADD ".$db->dbh->quote_identifier($columnName)." ". $dbDataType
|
||||
"ALTER TABLE ".$db->quote_identifier($thingyTableName)
|
||||
." ADD ".$db->quote_identifier($columnName)." ". $dbDataType
|
||||
);
|
||||
|
||||
return $newFieldId;
|
||||
|
|
@ -154,7 +154,7 @@ sub addThing {
|
|||
}
|
||||
}
|
||||
|
||||
$db->write("create table ".$db->dbh->quote_identifier("Thingy_".$newThingId)."(
|
||||
$db->write("create table ".$db->quote_identifier("Thingy_".$newThingId)."(
|
||||
thingDataId CHAR(22) binary not null,
|
||||
dateCreated int not null,
|
||||
createdById CHAR(22) not null,
|
||||
|
|
@ -250,7 +250,7 @@ sub badOtherThing {
|
|||
my ($otherThingTableExists) = $db->quickArray('show tables like ?',[$tableName]);
|
||||
return $i18n->get('other thing missing message') unless $otherThingTableExists;
|
||||
my ($otherThingFieldExists) = $db->quickArray(
|
||||
sprintf('show columns from %s like ?', $db->dbh->quote_identifier($tableName)),
|
||||
sprintf('show columns from %s like ?', $db->quote_identifier($tableName)),
|
||||
[$fieldName]);
|
||||
return $i18n->get('other thing field missing message') unless $otherThingFieldExists;
|
||||
return undef;
|
||||
|
|
@ -389,11 +389,11 @@ sub deleteField {
|
|||
,[$deletedSequenceNumber]);
|
||||
}
|
||||
|
||||
my ($columnExists) = $db->quickArray("show columns from ".$db->dbh->quote_identifier("Thingy_".$thingId)
|
||||
my ($columnExists) = $db->quickArray("show columns from ".$db->quote_identifier("Thingy_".$thingId)
|
||||
." like ".$db->quote("field_".$fieldId));
|
||||
if ($columnExists){
|
||||
$db->write("ALTER TABLE ".$db->dbh->quote_identifier("Thingy_".$thingId)." DROP "
|
||||
.$db->dbh->quote_identifier("field_".$fieldId));
|
||||
$db->write("ALTER TABLE ".$db->quote_identifier("Thingy_".$thingId)." DROP "
|
||||
.$db->quote_identifier("field_".$fieldId));
|
||||
}
|
||||
$error->info("Deleted field: $fieldId in thing: $thingId.");
|
||||
return undef;
|
||||
|
|
@ -525,7 +525,7 @@ sub deleteThing {
|
|||
|
||||
$self->deleteCollateral("Thingy_things","thingId",$thingId);
|
||||
$self->deleteCollateral("Thingy_fields","thingId",$thingId);
|
||||
$session->db->write("drop table if exists ".$session->db->dbh->quote_identifier("Thingy_".$thingId));
|
||||
$session->db->write("drop table if exists ".$session->db->quote_identifier("Thingy_".$thingId));
|
||||
|
||||
$error->info("Deleted thing: $thingId.");
|
||||
return undef;
|
||||
|
|
@ -568,7 +568,7 @@ sub editThingDataSave {
|
|||
$thingData{ipAddress} = $session->request->address;
|
||||
}
|
||||
else {
|
||||
%thingData = $session->db->quickHash("select * from ".$session->db->dbh->quote_identifier("Thingy_".$thingId)
|
||||
%thingData = $session->db->quickHash("select * from ".$session->db->quote_identifier("Thingy_".$thingId)
|
||||
." where thingDataId = ?",[$thingDataId]);
|
||||
}
|
||||
|
||||
|
|
@ -1125,7 +1125,7 @@ sub getViewThingVars {
|
|||
|
||||
return undef unless ($thingId && $thingDataId);
|
||||
|
||||
my %thingData = $db->quickHash("select * from ".$db->dbh->quote_identifier("Thingy_".$thingId)
|
||||
my %thingData = $db->quickHash("select * from ".$db->quote_identifier("Thingy_".$thingId)
|
||||
." where thingDataId = ?",[$thingDataId]);
|
||||
|
||||
if (%thingData) {
|
||||
|
|
@ -1212,7 +1212,7 @@ sub hasEnteredMaxPerUser {
|
|||
return 0 unless $maxEntriesPerUser;
|
||||
|
||||
my $numberOfEntries = $session->db->quickScalar("select count(*) "
|
||||
."from ".$session->db->dbh->quote_identifier("Thingy_".$thingId)." where createdById=?",[$session->user->userId]);
|
||||
."from ".$session->db->quote_identifier("Thingy_".$thingId)." where createdById=?",[$session->user->userId]);
|
||||
|
||||
if($numberOfEntries < $maxEntriesPerUser){
|
||||
return 0;
|
||||
|
|
@ -1362,7 +1362,7 @@ override purge => sub {
|
|||
my $db = $self->session->db;
|
||||
my @thingIds = $db->buildArray("select thingId from Thingy_things where assetId = ?", [$self->getId]);
|
||||
foreach my $thingId (@thingIds){
|
||||
$db->write("drop table if exists ".$db->dbh->quote_identifier("Thingy_".$thingId));
|
||||
$db->write("drop table if exists ".$db->quote_identifier("Thingy_".$thingId));
|
||||
}
|
||||
$db->write("delete from Thingy_things where assetId = ?",[$self->getId]);
|
||||
$db->write("delete from Thingy_fields where assetId = ?",[$self->getId]);
|
||||
|
|
@ -1450,9 +1450,9 @@ sub _updateFieldType {
|
|||
my $columnName = "field_".$fieldId;
|
||||
$error->info("changing column: $columnName, table: $thingyTableName");
|
||||
$self->session->db->write(
|
||||
"ALTER TABLE ".$db->dbh->quote_identifier($thingyTableName).
|
||||
" CHANGE ".$db->dbh->quote_identifier($columnName)." "
|
||||
.$db->dbh->quote_identifier($columnName)." ".$dbDataType
|
||||
"ALTER TABLE ".$db->quote_identifier($thingyTableName).
|
||||
" CHANGE ".$db->quote_identifier($columnName)." "
|
||||
.$db->quote_identifier($columnName)." ".$dbDataType
|
||||
);
|
||||
}
|
||||
return undef;
|
||||
|
|
@ -2320,7 +2320,7 @@ sub canEditThingData {
|
|||
else {
|
||||
if ($thingProperties->{groupIdEdit} eq 'owner'){
|
||||
my $owner = $session->db->quickScalar("select createdById "
|
||||
."from ".$session->db->dbh->quote_identifier("Thingy_".$thingId)
|
||||
."from ".$session->db->quote_identifier("Thingy_".$thingId)
|
||||
." where thingDataId = ?",[$thingDataId]);
|
||||
if ($session->user->userId eq $owner || $self->canEdit){
|
||||
return 1;
|
||||
|
|
@ -2366,7 +2366,7 @@ sub canViewThingData {
|
|||
|
||||
if ($thingProperties->{groupIdView} eq 'owner'){
|
||||
my $owner = $session->db->quickScalar("select createdById "
|
||||
."from ".$session->db->dbh->quote_identifier("Thingy_".$thingId)
|
||||
."from ".$session->db->quote_identifier("Thingy_".$thingId)
|
||||
." where thingDataId = ?",[$thingDataId]);
|
||||
if ($session->user->userId eq $owner || $self->canEdit){
|
||||
return 1;
|
||||
|
|
@ -2447,7 +2447,7 @@ sub editThingData {
|
|||
|
||||
if ($thingDataId ne "new"){
|
||||
# Get Field Values
|
||||
%thingData = $session->db->quickHash("select * from ".$session->db->dbh->quote_identifier("Thingy_".$thingId)
|
||||
%thingData = $session->db->quickHash("select * from ".$session->db->quote_identifier("Thingy_".$thingId)
|
||||
." where thingDataId = ?",[$thingDataId]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ sub getManagerPaginator {
|
|||
|
||||
my $p = WebGUI::Paginator->new( $session, '', $rowsPerPage, 'pn', $currentPage );
|
||||
|
||||
my $orderBy = $session->db->dbh->quote_identifier( $orderByColumn ) . ' ' . $orderByDirection;
|
||||
my $orderBy = $session->db->quote_identifier( $orderByColumn ) . ' ' . $orderByDirection;
|
||||
$p->setDataByArrayRef( $asset->getLineage( ['children'], { orderByClause => $orderBy } ) );
|
||||
|
||||
return $p;
|
||||
|
|
|
|||
|
|
@ -1598,8 +1598,8 @@ sub resetGroupFields {
|
|||
foreach my $tableName (keys %{ $tableCache }) {
|
||||
foreach my $fieldName (@{ $tableCache->{$tableName} }) {
|
||||
my $sql = sprintf 'UPDATE %s SET %s=3 where %s=?',
|
||||
$db->dbh->quote_identifier($tableName),
|
||||
(($db->dbh->quote_identifier($fieldName)) x 2);
|
||||
$db->quote_identifier($tableName),
|
||||
(($db->quote_identifier($fieldName)) x 2);
|
||||
$db->write($sql, [ $gid ]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ sub create {
|
|||
|
||||
# Add the column to the userProfileData table
|
||||
$db->write(
|
||||
"ALTER TABLE userProfileData ADD " . $db->dbh->quote_identifier($id)
|
||||
"ALTER TABLE userProfileData ADD " . $db->quote_identifier($id)
|
||||
. $dbDataType
|
||||
);
|
||||
|
||||
|
|
@ -194,7 +194,7 @@ sub delete {
|
|||
my $db = $self->session->db;
|
||||
|
||||
# Remove the column from the userProfileData table
|
||||
$db->write("ALTER TABLE userProfileData DROP " . $db->dbh->quote_identifier($self->getId));
|
||||
$db->write("ALTER TABLE userProfileData DROP " . $db->quote_identifier($self->getId));
|
||||
|
||||
# Remove the record
|
||||
$db->deleteRow("userProfileField","fieldName",$self->getId);
|
||||
|
|
@ -808,8 +808,8 @@ sub rename {
|
|||
|
||||
$self->session->db->write(
|
||||
"ALTER TABLE userProfileData "
|
||||
. "CHANGE " . $db->dbh->quote_identifier($self->getId)
|
||||
. $db->dbh->quote_identifier($newName) . " " . $dbDataType
|
||||
. "CHANGE " . $db->quote_identifier($self->getId)
|
||||
. $db->quote_identifier($newName) . " " . $dbDataType
|
||||
);
|
||||
|
||||
# Update the record
|
||||
|
|
@ -928,7 +928,7 @@ sub set {
|
|||
|
||||
my $sql
|
||||
= "ALTER TABLE userProfileData MODIFY COLUMN "
|
||||
. $db->dbh->quote_identifier($self->getId) . q{ }
|
||||
. $db->quote_identifier($self->getId) . q{ }
|
||||
. $dbDataType
|
||||
;
|
||||
|
||||
|
|
|
|||
|
|
@ -1392,7 +1392,7 @@ sub update {
|
|||
if ( exists $properties->{$key} ) {
|
||||
# Delete the value because it's not a profile field
|
||||
my $value = delete $properties->{$key};
|
||||
push @userFields, $db->dbh->quote_identifier( $key ) . " = ?";
|
||||
push @userFields, $db->quote_identifier( $key ) . " = ?";
|
||||
push @userValues, $value;
|
||||
$self->{_user}->{$key} = $value;
|
||||
}
|
||||
|
|
@ -1412,7 +1412,7 @@ sub update {
|
|||
$self->session->errorHandler->warn("No such profile field: $key");
|
||||
next;
|
||||
}
|
||||
push @profileFields, $db->dbh->quote_identifier( $key ) . " = ?";
|
||||
push @profileFields, $db->quote_identifier( $key ) . " = ?";
|
||||
push @profileValues, $properties->{ $key };
|
||||
$self->{_profile}->{$key} = $properties->{ $key };
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue