Skip to content

Commit

Permalink
Fixed style problems flagged on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
cmacmackin committed Nov 30, 2023
1 parent 38630c3 commit de60ccf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion meta/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function addLeftJoin($leftalias, $righttable, $rightalias, $onclause)
throw new StructException('Table Alias already exists');
}

if (count($this->from) > 0){
if (count($this->from) > 0) {
$pos = 0;
$matches = [];
preg_match_all('/\w+(?=\.\w+)/', $onclause, $matches);
Expand Down
23 changes: 19 additions & 4 deletions types/AbstractBaseType.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,12 @@ public function filter(QueryBuilderWhere $add, $tablealias, $colname, $comp, $va
{
$additional_join = $this->getAdditionalJoinForComparison($add, $tablealias, $colname);
if (!is_null($additional_join)) {
$add->getQB()->addLeftJoin($additional_join[0], $additional_join[1], $additional_join[2], $additional_join[3]);
$add->getQB()->addLeftJoin(
$additional_join[0],
$additional_join[1],
$additional_join[2],
$additional_join[3]
);
$oldalias = $tablealias;
$tablealias = $additional_join[2];
} else {
Expand Down Expand Up @@ -506,7 +511,13 @@ protected function equalityComparison($lhs, $rhs)
}
if (!$lhs_array) $lhs = array_fill(0, $nrhs, $lhs);
if (!$rhs_array) $rhs = array_fill(0, $nlhs, $rhs);
$comparisons = array_map(function ($l, $r) { return "($l = $r)"; }, $lhs, $rhs);
$comparisons = array_map(
function ($l, $r) {
return "($l = $r)";
},
$lhs,
$rhs
);
return implode(' OR ', $comparisons);
}

Expand All @@ -531,8 +542,12 @@ public function joinCondition($QB, &$left_table, $left_colname, $right_table, $r
$add = new QueryBuilderWhere($QB);
$op = 'AND';
$additional_join = $this->getAdditionalJoinForComparison($add, $left_table, $left_colname);
// FIXME: How to work with multiple lhs or rhs values (i.e., due to Page types)?
// In rhs secondary join, compare lhs ID and (possibly) title against rhs title only. In returned join condition, compare against secondary PID and the column value against lhs ID/title. At most one side of comparison will have multiple values.
// When dealing with joins over page types:
// In rhs secondary join, compare lhs ID and (possibly) title
// against rhs title only. In returned join condition, compare
// against secondary PID and the column value against lhs
// ID/title. At most one side of comparison will have multiple
// values.
if (!is_null($additional_join)) {
$add->getQB()->addLeftJoin($additional_join[0], $additional_join[1], $additional_join[2], $additional_join[3]);
$lhs = $this->getSqlCompareValue($add, $additional_join[2], $left_table, $left_colname, $op);
Expand Down
1 change: 0 additions & 1 deletion types/AutoSummary.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,4 @@ protected function getAdditionalJoinForComparison(QueryBuilderWhere &$add, $tabl
$rightalias = $QB->generateTableAlias();
return [$tablealias, 'titles', $rightalias, "$tablealias.pid = $rightalias.pid"];
}

}

0 comments on commit de60ccf

Please sign in to comment.