Commit b994c1a6 authored by romanb's avatar romanb

Fixed #697.

parent 260b9ae2
...@@ -611,6 +611,8 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module ...@@ -611,6 +611,8 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
$rootRecord->merge($dataSet[$parent]); $rootRecord->merge($dataSet[$parent]);
$this->processSingleInsert($rootRecord); $this->processSingleInsert($rootRecord);
$record->assignIdentifier($rootRecord->identifier());
} else { } else {
foreach ((array) $rootRecord->identifier() as $id => $value) { foreach ((array) $rootRecord->identifier() as $id => $value) {
$dataSet[$parent][$id] = $value; $dataSet[$parent][$id] = $value;
......
...@@ -1443,11 +1443,18 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count ...@@ -1443,11 +1443,18 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
$this->_state = Doctrine_Record::STATE_CLEAN; $this->_state = Doctrine_Record::STATE_CLEAN;
$this->_modified = array(); $this->_modified = array();
} else { } else {
$name = $this->_table->getIdentifier(); if (is_array($id)) {
$this->_id[$name] = $id; foreach ($id as $fieldName => $value) {
$this->_data[$name] = $id; $this->_id[$fieldName] = $value;
$this->_state = Doctrine_Record::STATE_CLEAN; $this->_data[$fieldName] = $value;
$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();
} }
} }
......
<?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()); ...@@ -25,6 +25,7 @@ $tickets->addTestCase(new Doctrine_Ticket_438_TestCase());
$tickets->addTestCase(new Doctrine_Ticket_638_TestCase()); $tickets->addTestCase(new Doctrine_Ticket_638_TestCase());
$tickets->addTestCase(new Doctrine_Ticket_673_TestCase()); $tickets->addTestCase(new Doctrine_Ticket_673_TestCase());
$tickets->addTestCase(new Doctrine_Ticket_626D_TestCase()); $tickets->addTestCase(new Doctrine_Ticket_626D_TestCase());
$tickets->addTestCase(new Doctrine_Ticket_697_TestCase());
$test->addTestCase($tickets); $test->addTestCase($tickets);
// Connection drivers (not yet fully tested) // Connection drivers (not yet fully tested)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment