mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-06 11:32:40 +00:00
Adding tests from 'Stephen Cuppert' to test incorrectly generate DELETE queries for habtm join tables that do not have a primary key when using PostgreSQL. Updating DboSource::_matchRecords() to only query the table if the supplied conditions are actually multi-table conditions. Fixes #459
This commit is contained in:
parent
190066fd51
commit
ea64588a81
2 changed files with 71 additions and 0 deletions
|
@ -1477,6 +1477,22 @@ class DboSource extends DataSource {
|
|||
} elseif ($conditions === null) {
|
||||
$conditions = $this->conditions($this->defaultConditions($model, $conditions, false), true, true, $model);
|
||||
} else {
|
||||
$noJoin = true;
|
||||
foreach ($conditions as $field => $value) {
|
||||
$originalField = $field;
|
||||
if (strpos($field, '.') !== false) {
|
||||
list($alias, $field) = explode('.', $field);
|
||||
}
|
||||
if (!$model->hasField($field)) {
|
||||
$noJoin = false;
|
||||
break;
|
||||
}
|
||||
$conditions[$field] = $value;
|
||||
unset($conditions[$originalField]);
|
||||
}
|
||||
if ($noJoin === true) {
|
||||
return $this->conditions($conditions);
|
||||
}
|
||||
$idList = $model->find('all', array(
|
||||
'fields' => "{$model->alias}.{$model->primaryKey}",
|
||||
'conditions' => $conditions
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue