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:
Mark Story 2010-03-15 22:55:14 -04:00
parent 190066fd51
commit ea64588a81
2 changed files with 71 additions and 0 deletions

View file

@ -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