Skip to content

Commit

Permalink
Removed unused code in findListWhere()
Browse files Browse the repository at this point in the history
  • Loading branch information
arnemorken committed Jan 15, 2025
1 parent 12bbd39 commit 786223e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 29 deletions.
19 changes: 4 additions & 15 deletions data/alasql/anyTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -952,17 +952,6 @@ anyTable.prototype.findListWhere = function(groupType,groupId,linkType,linkId,gr
}
}
}

// TODO! What's this for?
if (linkType == this.type && linkId != "nogroup") {
let db_id = this.type == "group" ? "'"+linkId+"'" : linkId;
let skip_str = this.tableName+"."+this.idKey+" != "+db_id+"";
if (where === "")
where = "WHERE ("+skip_str+") ";
else
where += " AND ("+skip_str+") ";
}

// Match with group table
if (groupId == "nogroup") {
// Search items not belonging to any group
Expand Down Expand Up @@ -1876,14 +1865,14 @@ anyTable.prototype.dbUpdateLinkList = async function(options)
await this.dbSearchItemListOfType(id,link_type);

if (this.error)
return null;
return Promise.resolve(null);

if (this.data) {
// TODO! Why must we do this?
this.data["data"] = this.data;
// Prepare data
$.extend(true,this.data["data"],this.data); // TODO! Could slow down execution if large data structure // TODO! jsQuery method!
this.data["nogroup"] = null;
}
return this;
return Promise.resolve(this);
}; // dbUpdateLinkList

anyTable.prototype.dbValidateUpdateLinkList = function(options)
Expand Down
20 changes: 6 additions & 14 deletions data/mysql/anyTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -1170,8 +1170,8 @@ protected function findListWhere($groupType=null,$groupId=null,$linkType=null,$l
$has_group_linktable = $this->tableExists($this->mTableNameGroupLink);

// If has parent_id while being a list-for list
if ($this->hasParentId() && (isset($linkType) && $linkType != "" || (($linkId && $linkId !== 0)))) {
if (($linkId && $linkId !== 0) && is_numeric($linkId) && (!isset($linkType) || $linkType == "" || $linkType == $this->mType)) {
if ($this->hasParentId() && (isset($linkType) && $linkType != "" || ($linkId || $linkId === 0))) {
if (($linkId || $linkId === 0) && is_numeric($linkId) && (!isset($linkType) || $linkType == "" || $linkType == $this->mType)) {
$gstr = $this->mTableName.".".$this->mIdKeyTable." IN ( ".
"SELECT ".$this->mTableName.".".$this->mIdKeyTable." ".
"FROM (SELECT @pv := '".$linkId."') ".
Expand All @@ -1188,17 +1188,6 @@ protected function findListWhere($groupType=null,$groupId=null,$linkType=null,$l
}
}
}

// TODO! What's this for?
if ($linkType == $this->mType && $linkId != "nogroup") {
$db_id = $this->mType == "group" ? "'".$linkId."'" : $linkId;
$skip_str = $this->mTableName.".".$this->mIdKeyTable." != ".$db_id."";
if ($where === "")
$where = "WHERE (".$skip_str.") ";
else
$where .= " AND (".$skip_str.") ";
}

// Match with group table
if ($grouping) {
if ($groupId == "nogroup" && $has_group_linktable) {
Expand Down Expand Up @@ -2297,13 +2286,16 @@ public function dbUpdateLinkList()
$this->setMessage($this->mUpdateSuccessMsg);

// Get the (updated) list for the item
$link_id = Parameters::get("link_id");
$type = Parameters::get("type");
$this->dbSearchItemListOfType($id,$link_type);

if ($this->isError())
return null;

if (isset($this->mData)) {
$this->mData["data"] = $this->mData;
// Prepare data
$this->mData["data"] = $this->mData; // TODO! clone?
$this->mData["nogroup"] = null;
}
return $this->mData;
Expand Down

0 comments on commit 786223e

Please sign in to comment.