Skip to content

Commit

Permalink
Merge pull request #24993 from aydun/joinable_fix
Browse files Browse the repository at this point in the history
Allow Joinables to be added to tables without specifying a base column
  • Loading branch information
colemanw authored Nov 17, 2022
2 parents 1b43295 + 791b250 commit 2cd552f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions Civi/Api4/Service/Schema/Joinable/Joinable.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,15 @@ public function __construct($targetTable, $targetColumn, $alias = NULL) {
*/
public function getConditionsForJoin(string $baseTableAlias, string $targetTableAlias) {
$conditions = [];
$conditions[] = sprintf(
'`%s`.`%s` = `%s`.`%s`',
$baseTableAlias,
$this->baseColumn,
$targetTableAlias,
$this->targetColumn
);
if ($this->baseColumn && $this->targetColumn) {
$conditions[] = sprintf(
'`%s`.`%s` = `%s`.`%s`',
$baseTableAlias,
$this->baseColumn,
$targetTableAlias,
$this->targetColumn
);
}
$this->addExtraJoinConditions($conditions, $baseTableAlias, $targetTableAlias);
return $conditions;
}
Expand Down

0 comments on commit 2cd552f

Please sign in to comment.