Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixing issue where id = null could cause SQL errors when saving more …

…than one record with a null id. Fixes #675
  • Loading branch information...
commit 6add43a4bc250305442d3615bec5e56dde8cb11c 1 parent 3539660
@markstory markstory authored
View
2  cake/libs/model/model.php
@@ -1281,7 +1281,7 @@ function save($data = null, $validate = true, $fieldList = array()) {
}
}
- if (isset($this->data[$this->alias][$this->primaryKey]) && empty($this->data[$this->alias][$this->primaryKey])) {
+ if (empty($this->data[$this->alias][$this->primaryKey])) {
unset($this->data[$this->alias][$this->primaryKey]);
}
$fields = $values = array();
View
3  cake/tests/cases/libs/model/model_write.test.php
@@ -905,13 +905,14 @@ function testSaveWithCreate() {
* @return void
*/
function testSaveWithNullId() {
+ $this->loadFixtures('User');
$User =& new User();
$User->read(null, 1);
$User->data['User']['id'] = null;
$this->assertTrue($User->save(array('password' => 'test')));
$this->assertTrue($User->id > 0);
- $User->read(null, 2);
+ $result = $User->read(null, 2);
$User->data['User']['id'] = null;
$this->assertTrue($User->save(array('password' => 'test')));
$this->assertTrue($User->id > 0);

0 comments on commit 6add43a

Please sign in to comment.
Something went wrong with that request. Please try again.