Applying patch from 'ralph.marchildon' Fixes saving habtm data using 'with' data. Fixes #6077

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8021 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mark_story 2009-02-11 03:53:04 +00:00
parent d3ee6b31f1
commit b1b67c811c
2 changed files with 8 additions and 0 deletions

View file

@ -1309,6 +1309,8 @@ class Model extends Overloadable {
unset($values);
} elseif (isset($row[$this->hasAndBelongsToMany[$assoc]['associationForeignKey']])) {
$newData[] = $row;
} elseif (isset($row[$join][$this->hasAndBelongsToMany[$assoc]['associationForeignKey']])) {
$newData[] = $row[$join];
}
}

View file

@ -576,6 +576,12 @@ class ModelTest extends CakeTestCase {
'JoinThing' => array('doomed' => '1', 'something_id' => '1', 'something_else_id' => '2'))));
$this->assertEqual($result, $expected);
$expected = $TestModel->findById(1);
$TestModel->set($expected);
$TestModel->save();
$result = $TestModel->findById(1);
$this->assertEqual($result, $expected);
$TestModel->hasAndBelongsToMany['SomethingElse']['unique'] = false;
$TestModel->create(array(
'Something' => array('id' => 1),