Fixed #697.
This commit is contained in:
parent
260b9ae291
commit
b994c1a6f9
@ -611,6 +611,8 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
|
||||
$rootRecord->merge($dataSet[$parent]);
|
||||
|
||||
$this->processSingleInsert($rootRecord);
|
||||
|
||||
$record->assignIdentifier($rootRecord->identifier());
|
||||
} else {
|
||||
foreach ((array) $rootRecord->identifier() as $id => $value) {
|
||||
$dataSet[$parent][$id] = $value;
|
||||
|
@ -1443,11 +1443,18 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
|
||||
$this->_state = Doctrine_Record::STATE_CLEAN;
|
||||
$this->_modified = array();
|
||||
} else {
|
||||
$name = $this->_table->getIdentifier();
|
||||
$this->_id[$name] = $id;
|
||||
$this->_data[$name] = $id;
|
||||
$this->_state = Doctrine_Record::STATE_CLEAN;
|
||||
$this->_modified = array();
|
||||
if (is_array($id)) {
|
||||
foreach ($id as $fieldName => $value) {
|
||||
$this->_id[$fieldName] = $value;
|
||||
$this->_data[$fieldName] = $value;
|
||||
}
|
||||
} else {
|
||||
$name = $this->_table->getIdentifier();
|
||||
$this->_id[$name] = $id;
|
||||
$this->_data[$name] = $id;
|
||||
}
|
||||
$this->_state = Doctrine_Record::STATE_CLEAN;
|
||||
$this->_modified = array();
|
||||
}
|
||||
}
|
||||
|
||||
|
53
tests/Ticket/697TestCase.php
Normal file
53
tests/Ticket/697TestCase.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* Doctrine_Ticket_697_TestCase
|
||||
*
|
||||
* @package Doctrine
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @category Object Relational Mapping
|
||||
* @link www.phpdoctrine.com
|
||||
* @since 1.0
|
||||
* @version $Revision$
|
||||
*/
|
||||
|
||||
class Doctrine_Ticket_697_TestCase extends Doctrine_UnitTestCase
|
||||
{
|
||||
public function prepareData()
|
||||
{ }
|
||||
|
||||
public function prepareTables()
|
||||
{
|
||||
$this->tables = array('T697_Person', 'T697_User');
|
||||
parent::prepareTables();
|
||||
}
|
||||
|
||||
public function testIdsAreSetWhenSavingSubclassInstancesInCTI()
|
||||
{
|
||||
$p = new T697_Person();
|
||||
$p['name']='Rodrigo';
|
||||
$p->save();
|
||||
$this->assertEqual(1, $p->id);
|
||||
|
||||
$u = new T697_User();
|
||||
$u['name']='Fernandes';
|
||||
$u['password']='Doctrine RULES';
|
||||
$u->save();
|
||||
$this->assertEqual(2, $u->id);
|
||||
}
|
||||
}
|
||||
|
||||
class T697_Person extends Doctrine_Record
|
||||
{
|
||||
public function setTableDefinition()
|
||||
{
|
||||
$this->hasColumn('name', 'string', 30);
|
||||
}
|
||||
}
|
||||
|
||||
//Class table inheritance
|
||||
class T697_User extends T697_Person {
|
||||
public function setTableDefinition()
|
||||
{
|
||||
$this->hasColumn('password', 'string', 30);
|
||||
}
|
||||
}
|
@ -25,6 +25,7 @@ $tickets->addTestCase(new Doctrine_Ticket_438_TestCase());
|
||||
$tickets->addTestCase(new Doctrine_Ticket_638_TestCase());
|
||||
$tickets->addTestCase(new Doctrine_Ticket_673_TestCase());
|
||||
$tickets->addTestCase(new Doctrine_Ticket_626D_TestCase());
|
||||
$tickets->addTestCase(new Doctrine_Ticket_697_TestCase());
|
||||
$test->addTestCase($tickets);
|
||||
|
||||
// Connection drivers (not yet fully tested)
|
||||
|
Loading…
x
Reference in New Issue
Block a user