mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-05 19:12:42 +00:00
Test for a self join only when needed.
This commit is contained in:
parent
a2f043d2a3
commit
b7527c6c3b
1 changed files with 8 additions and 9 deletions
|
@ -1599,9 +1599,9 @@ class DboSource extends DataSource {
|
||||||
$this->getConstraint($type, $Model, $LinkModel, $association, array_merge($assocData, compact('external')))
|
$this->getConstraint($type, $Model, $LinkModel, $association, array_merge($assocData, compact('external')))
|
||||||
);
|
);
|
||||||
|
|
||||||
$selfJoin = ($Model->name === $LinkModel->name);
|
if ($external) {
|
||||||
|
// Self join
|
||||||
if ($external && !$selfJoin) {
|
if ($Model->name !== $LinkModel->name) {
|
||||||
$modelAlias = $Model->alias;
|
$modelAlias = $Model->alias;
|
||||||
foreach ($conditions as $key => $condition) {
|
foreach ($conditions as $key => $condition) {
|
||||||
if (is_numeric($key) && strpos($condition, $modelAlias . '.') !== false) {
|
if (is_numeric($key) && strpos($condition, $modelAlias . '.') !== false) {
|
||||||
|
@ -1610,7 +1610,6 @@ class DboSource extends DataSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($external) {
|
|
||||||
$query = array_merge($assocData, array(
|
$query = array_merge($assocData, array(
|
||||||
'conditions' => $conditions,
|
'conditions' => $conditions,
|
||||||
'table' => $this->fullTableName($LinkModel),
|
'table' => $this->fullTableName($LinkModel),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue