From 296f9df45e5cc58799a6919e51e8ee35b0c18fc2 Mon Sep 17 00:00:00 2001 From: mmeissonnier Date: Mon, 4 Sep 2023 17:01:29 +0200 Subject: [PATCH 1/4] criteria uses named joins internally It already has a named Api, using auto indexes breaks ModelCriteria where --- src/Propel/Runtime/ActiveQuery/Criteria.php | 23 +++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/Propel/Runtime/ActiveQuery/Criteria.php b/src/Propel/Runtime/ActiveQuery/Criteria.php index 1145c2c01..06bbc0af4 100644 --- a/src/Propel/Runtime/ActiveQuery/Criteria.php +++ b/src/Propel/Runtime/ActiveQuery/Criteria.php @@ -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; } @@ -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; } @@ -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 $join A name for the join * * @return $this A modified Criteria object */ - 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; From 0e488557f6e8ca8a09200f0a04ff431a9586adb6 Mon Sep 17 00:00:00 2001 From: mmeissonnier Date: Mon, 4 Sep 2023 17:48:46 +0200 Subject: [PATCH 2/4] name over right column instead of left for criteria's joins --- src/Propel/Runtime/ActiveQuery/Criteria.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Propel/Runtime/ActiveQuery/Criteria.php b/src/Propel/Runtime/ActiveQuery/Criteria.php index 06bbc0af4..bad9fd18c 100644 --- a/src/Propel/Runtime/ActiveQuery/Criteria.php +++ b/src/Propel/Runtime/ActiveQuery/Criteria.php @@ -1088,11 +1088,10 @@ public function addJoin($left, $right, ?string $joinType = null) $join->setJoinType($joinType); - if ($leftTableAlias !== null) { - $this->addJoinObject($join, $leftTableAlias); - } - else { - $this->addJoinObject($join, $leftTableName); + if ($rightTableAlias !== null) { + $this->addJoinObject($join, $rightTableAlias); + } else { + $this->addJoinObject($join, $rightTableName); } return $this; @@ -1172,11 +1171,10 @@ public function addMultipleJoin(array $conditions, ?string $joinType = null) $join->setJoinType($joinType); $join->setJoinCondition($joinCondition); - if ($join->getLeftTableAlias()) { - $this->addJoinObject($join, $join->getLeftTableAlias()); - } - else { - $this->addJoinObject($join, $join->getLeftTableName()); + if ($join->getRightTableAlias()) { + $this->addJoinObject($join, $join->getRightTableAlias()); + } else { + $this->addJoinObject($join, $join->getRightTableName()); } return $this; From 85dbe48fd0b28f04fb2964634d06c4d648362fdc Mon Sep 17 00:00:00 2001 From: mmeissonnier Date: Mon, 4 Sep 2023 18:54:18 +0200 Subject: [PATCH 3/4] fix doctype, remove now useless addJoinObject from modelCriteria --- src/Propel/Runtime/ActiveQuery/Criteria.php | 4 ++-- .../Runtime/ActiveQuery/ModelCriteria.php | 23 ------------------- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/src/Propel/Runtime/ActiveQuery/Criteria.php b/src/Propel/Runtime/ActiveQuery/Criteria.php index bad9fd18c..3013d1ec4 100644 --- a/src/Propel/Runtime/ActiveQuery/Criteria.php +++ b/src/Propel/Runtime/ActiveQuery/Criteria.php @@ -1184,9 +1184,9 @@ 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 $join A name for the join + * @param string|null $name * - * @return $this A modified Criteria object + * @return $this The current object, for fluid interface */ public function addJoinObject(Join $join, ?string $name = null) { diff --git a/src/Propel/Runtime/ActiveQuery/ModelCriteria.php b/src/Propel/Runtime/ActiveQuery/ModelCriteria.php index cf4caf25d..c9d85853c 100644 --- a/src/Propel/Runtime/ActiveQuery/ModelCriteria.php +++ b/src/Propel/Runtime/ActiveQuery/ModelCriteria.php @@ -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() From feb4f18bf8cb39cf97e9a97023b2090444978b9b Mon Sep 17 00:00:00 2001 From: mmeissonnier Date: Tue, 5 Sep 2023 09:53:49 +0200 Subject: [PATCH 4/4] Revert "name over right column instead of left for criteria's joins" This reverts commit 0e488557f6e8ca8a09200f0a04ff431a9586adb6. --- src/Propel/Runtime/ActiveQuery/Criteria.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Propel/Runtime/ActiveQuery/Criteria.php b/src/Propel/Runtime/ActiveQuery/Criteria.php index 3013d1ec4..d9d2c82a6 100644 --- a/src/Propel/Runtime/ActiveQuery/Criteria.php +++ b/src/Propel/Runtime/ActiveQuery/Criteria.php @@ -1088,10 +1088,11 @@ public function addJoin($left, $right, ?string $joinType = null) $join->setJoinType($joinType); - if ($rightTableAlias !== null) { - $this->addJoinObject($join, $rightTableAlias); - } else { - $this->addJoinObject($join, $rightTableName); + if ($leftTableAlias !== null) { + $this->addJoinObject($join, $leftTableAlias); + } + else { + $this->addJoinObject($join, $leftTableName); } return $this; @@ -1171,10 +1172,11 @@ public function addMultipleJoin(array $conditions, ?string $joinType = null) $join->setJoinType($joinType); $join->setJoinCondition($joinCondition); - if ($join->getRightTableAlias()) { - $this->addJoinObject($join, $join->getRightTableAlias()); - } else { - $this->addJoinObject($join, $join->getRightTableName()); + if ($join->getLeftTableAlias()) { + $this->addJoinObject($join, $join->getLeftTableAlias()); + } + else { + $this->addJoinObject($join, $join->getLeftTableName()); } return $this;