Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

criteria uses named joins internally #1977

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions src/Propel/Runtime/ActiveQuery/Criteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,12 @@ public function addJoin($left, $right, ?string $joinType = null)

$join->setJoinType($joinType);

$this->addJoinObject($join);
if ($leftTableAlias !== null) {
$this->addJoinObject($join, $leftTableAlias);
}
else {
$this->addJoinObject($join, $leftTableName);
}

return $this;
}
Expand Down Expand Up @@ -1167,7 +1172,12 @@ public function addMultipleJoin(array $conditions, ?string $joinType = null)
$join->setJoinType($joinType);
$join->setJoinCondition($joinCondition);

$this->addJoinObject($join);
if ($join->getLeftTableAlias()) {
$this->addJoinObject($join, $join->getLeftTableAlias());
}
else {
$this->addJoinObject($join, $join->getLeftTableName());
}

return $this;
}
Expand All @@ -1176,13 +1186,18 @@ public function addMultipleJoin(array $conditions, ?string $joinType = null)
* Add a join object to the Criteria
*
* @param \Propel\Runtime\ActiveQuery\Join $join A join object
* @param string|null $name
*
* @return $this A modified Criteria object
* @return $this The current object, for fluid interface
*/
public function addJoinObject(Join $join)
public function addJoinObject(Join $join, ?string $name = null)
{
if (!in_array($join, $this->joins)) { // compare equality, NOT identity
$this->joins[] = $join;
if ($name === null) {
$this->joins[] = $join;
} else {
$this->joins[$name] = $join;
}
}

return $this;
Expand Down
23 changes: 0 additions & 23 deletions src/Propel/Runtime/ActiveQuery/ModelCriteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -725,29 +725,6 @@ public function setJoinCondition(string $name, $condition)
return $this;
}

/**
* Add a join object to the Criteria
*
* @see Criteria::addJoinObject()
*
* @param \Propel\Runtime\ActiveQuery\Join $join A join object
* @param string|null $name
*
* @return $this The current object, for fluid interface
*/
public function addJoinObject(Join $join, ?string $name = null)
{
if (!in_array($join, $this->joins)) { // compare equality, NOT identity
if ($name === null) {
$this->joins[] = $join;
} else {
$this->joins[$name] = $join;
}
}

return $this;
}

/**
* Adds a JOIN clause to the query and hydrates the related objects
* Shortcut for $c->join()->with()
Expand Down
Loading