1
0
mirror of synced 2025-01-18 06:21:40 +03:00
This commit is contained in:
romanb 2007-12-28 11:51:48 +00:00
parent 260b9ae291
commit b994c1a6f9
4 changed files with 68 additions and 5 deletions

View File

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

View File

@ -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();
}
}

View 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);
}
}

View File

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