Adding non-null association key fix in Model, and updating Model::isUnique() to account for current record, fixes #3859, closes #2032

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6336 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2008-01-08 06:29:51 +00:00
parent 2c4a8f4131
commit b7abaf019c

View file

@ -692,7 +692,7 @@ class Model extends Overloadable {
$class = $assocKey;
foreach ($this->__associationKeys[$type] as $key) {
if (!isset($this->{$type}[$assocKey][$key]) || $this->{$type}[$assocKey][$key] == null) {
if (!isset($this->{$type}[$assocKey][$key]) || $this->{$type}[$assocKey][$key] === null) {
$data = '';
switch($key) {
@ -1221,13 +1221,14 @@ class Model extends Overloadable {
$success = $created = false;
} else {
$created = true;
if (!empty($this->belongsTo)) {
$this->updateCounterCache();
}
}
}
}
if (!empty($this->belongsTo)) {
$this->updateCounterCache(array(), $created);
}
if (!empty($joined) && $success === true) {
$this->__saveMulti($joined, $this->id);
}
@ -1922,6 +1923,9 @@ class Model extends Overloadable {
if ($or) {
$fields = array('or' => $fields);
}
if (!empty($this->id)) {
$fields[$this->alias . '.' . $this->primaryKey] = '!= ' . $this->id;
}
return ($this->find('count', array('conditions' => $fields)) == 0);
}
/**