Skip to content

Commit

Permalink
Improved checks for when grouping should be applied.
Browse files Browse the repository at this point in the history
  • Loading branch information
arnemorken committed Aug 31, 2024
1 parent 20c14ea commit 6c017c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions data/alasql/anyTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -667,13 +667,13 @@ anyTable.prototype.dbSearchList = async function(options)
if (this._initSearch(options) == -1)
return Promise.resolve(null);

let linkId = options ? options.linkId : null;
let linkType = options ? options.linkType : null;
let groupId = options ? options.groupId : null; // If "groupId" is specified, we need only search in that group
let groupType = options ? options.groupType : null; // If "groupType" is specified, search only for groups of that type
let grouping = options && typeof options.grouping == "boolean" ? options.grouping : true;
let linkId = options ? options.linkId : null;
let linkType = options ? options.linkType : null;
let groupId = options ? options.groupId : null; // If "groupId" is specified, we need only search in that group
let groupType = options ? options.groupType : null; // If "groupType" is specified, search only for groups of that type
let grouping = this.type == "group" ? false : options && typeof options.grouping == "boolean" ? options.grouping : true;
grouping = grouping !== false && grouping !== "false" && grouping !== "0";
let simple = options && typeof options.simple == "boolean" ? options.simple : false; // In a "simple" list search we get only the id, name and parent_id
let simple = options && typeof options.simple == "boolean" ? options.simple : false; // In a "simple" list search we get only the id, name and parent_id
simple = simple === true || simple === "true" || simple === "1";

// Get group data, unless we are searching in a specific group
Expand Down Expand Up @@ -1273,7 +1273,7 @@ anyTable.prototype.buildGroupTreeAndAttach = function(group_data,linkId,grouping
let ngidx = gidx;
if (!data_tree[ngidx])
data_tree[ngidx] = {};
if (grouping && this.data[gidx]) { // Add a head data layer
if ((grouping || this.type == "group") && this.hostTable == null && this.data[gidx]) { // Add a head data layer
data_tree[ngidx]["head"] = "group";
data_tree[ngidx]["group_type"] = this.type;
data_tree[ngidx]["group_id"] = ngidx;
Expand Down
4 changes: 2 additions & 2 deletions data/mysql/anyTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ protected function dbSearchList($linkId=null,$linkType=null,$groupId=null,$group
$groupType = Parameters::get("group_type"); // If "groupType" is specified, search only for groups of that type
if ($grouping == null)
$grouping = Parameters::get("grouping");
$grouping = $grouping && $grouping !== "false" && $grouping !== "0";
$grouping = $this->mType == "group" ? false : $grouping && $grouping !== "false" && $grouping !== "0";
if ($simple == null)
$simple = Parameters::get("simple"); // In a "simple" list search we get only the id, name and parent_id
$simple = $simple === true || $simple === "true" || $simple === "1";
Expand Down Expand Up @@ -1598,7 +1598,7 @@ protected function buildGroupTreeAndAttach($group_data,$linkId=null,$grouping=tr
$ngidx = isInteger($gidx) ? "+".$gidx : $gidx;
if (!isset($data_tree[$ngidx]))
$data_tree[$ngidx] = array();
if ($grouping && isset($this->mData[$gidx])) { // Add a head data layer
if (($grouping || $this->mType == "group") && $this->mHostTable == null && isset($this->mData[$gidx])) { // Add a head data layer
$data_tree[$ngidx]["head"] = "group";
$data_tree[$ngidx]["group_type"] = $this->mType;
$data_tree[$ngidx]["group_id"] = $ngidx;
Expand Down

0 comments on commit 6c017c1

Please sign in to comment.