Commit b6e385d2 authored by romanb's avatar romanb

fixed regression

parent d9733637
...@@ -501,9 +501,9 @@ class Doctrine_DBAL_Platforms_SqlitePlatform extends Doctrine_DBAL_Platforms_Abs ...@@ -501,9 +501,9 @@ class Doctrine_DBAL_Platforms_SqlitePlatform extends Doctrine_DBAL_Platforms_Abs
} }
} }
if ( ! $autoinc && isset($options['primary']) && ! empty($options['primary'])) { if (isset($options['primary']) && ! empty($options['primary'])) {
$keyColumns = array_values($options['primary']); $keyColumns = array_values($options['primary']);
$keyColumns = array_map(array($this->_conn, 'quoteIdentifier'), $keyColumns); $keyColumns = array_map(array($this, 'quoteIdentifier'), $keyColumns);
$queryFields.= ', PRIMARY KEY('.implode(', ', $keyColumns).')'; $queryFields.= ', PRIMARY KEY('.implode(', ', $keyColumns).')';
} }
......
...@@ -48,9 +48,14 @@ abstract class Doctrine_DBAL_Types_Type ...@@ -48,9 +48,14 @@ abstract class Doctrine_DBAL_Types_Type
*/ */
public static function getType($name) public static function getType($name)
{ {
if (is_object($name)) {
try { throw new Exception(); }
catch (Exception $e) { echo $e->getTraceAsString(); }
die();
}
if ( ! isset(self::$_typeObjects[$name])) { if ( ! isset(self::$_typeObjects[$name])) {
if ( ! isset(self::$_typesMap[$name])) { if ( ! isset(self::$_typesMap[$name])) {
throw Doctrine_Exception::unknownType($name); throw new Doctrine_Exception("Unknown type: $name");
} }
self::$_typeObjects[$name] = new self::$_typesMap[$name](); self::$_typeObjects[$name] = new self::$_typesMap[$name]();
} }
......
...@@ -71,6 +71,7 @@ class Doctrine_ORM_Export_ClassExporter ...@@ -71,6 +71,7 @@ class Doctrine_ORM_Export_ClassExporter
$column['length'] = $mapping['length']; $column['length'] = $mapping['length'];
if ($class->isIdentifier($fieldName)) { if ($class->isIdentifier($fieldName)) {
$column['primary'] = true;
if ($class->isIdGeneratorIdentity()) { if ($class->isIdGeneratorIdentity()) {
$column['autoincrement'] = true; $column['autoincrement'] = true;
} }
......
...@@ -327,6 +327,8 @@ class Doctrine_ORM_Internal_Hydration_StandardHydrator extends Doctrine_ORM_Inte ...@@ -327,6 +327,8 @@ class Doctrine_ORM_Internal_Hydration_StandardHydrator extends Doctrine_ORM_Inte
} else { } else {
$fieldName = $this->_lookupFieldName($classMetadata, $columnName); $fieldName = $this->_lookupFieldName($classMetadata, $columnName);
$cache[$key]['isScalar'] = false; $cache[$key]['isScalar'] = false;
// cache type information
$cache[$key]['type'] = $classMetadata->getTypeOfColumn($columnName);
} }
$cache[$key]['fieldName'] = $fieldName; $cache[$key]['fieldName'] = $fieldName;
...@@ -337,15 +339,6 @@ class Doctrine_ORM_Internal_Hydration_StandardHydrator extends Doctrine_ORM_Inte ...@@ -337,15 +339,6 @@ class Doctrine_ORM_Internal_Hydration_StandardHydrator extends Doctrine_ORM_Inte
} else { } else {
$cache[$key]['isIdentifier'] = false; $cache[$key]['isIdentifier'] = false;
} }
// cache type information
$type = $classMetadata->getTypeOfColumn($columnName);
if ($type == 'integer' || $type == 'string') {
$cache[$key]['isSimpleType'] = true;
} else {
$cache[$key]['type'] = $type;
$cache[$key]['isSimpleType'] = false;
}
} }
$class = $this->_queryComponents[$cache[$key]['dqlAlias']]['metadata']; $class = $this->_queryComponents[$cache[$key]['dqlAlias']]['metadata'];
...@@ -361,13 +354,11 @@ class Doctrine_ORM_Internal_Hydration_StandardHydrator extends Doctrine_ORM_Inte ...@@ -361,13 +354,11 @@ class Doctrine_ORM_Internal_Hydration_StandardHydrator extends Doctrine_ORM_Inte
$id[$dqlAlias] .= '|' . $value; $id[$dqlAlias] .= '|' . $value;
} }
if ($cache[$key]['isSimpleType']) { if ($cache[$key]['isScalar']) {
$rowData[$dqlAlias][$fieldName] = $value; $rowData[$dqlAlias][$fieldName] = $value;
} else { } else {
$rowData[$dqlAlias][$fieldName] = $this->prepareValue( $rowData[$dqlAlias][$fieldName] = $cache[$key]['type']->convertToPHPValue($value);
$class, $fieldName, $value, $cache[$key]['type']);
} }
//$rowData[$dqlAlias][$fieldName] = $cache[$key]['type']->convertToObjectValue($value);
if ( ! isset($nonemptyComponents[$dqlAlias]) && $value !== null) { if ( ! isset($nonemptyComponents[$dqlAlias]) && $value !== null) {
$nonemptyComponents[$dqlAlias] = true; $nonemptyComponents[$dqlAlias] = true;
...@@ -412,31 +403,21 @@ class Doctrine_ORM_Internal_Hydration_StandardHydrator extends Doctrine_ORM_Inte ...@@ -412,31 +403,21 @@ class Doctrine_ORM_Internal_Hydration_StandardHydrator extends Doctrine_ORM_Inte
} else { } else {
$fieldName = $this->_lookupFieldName($classMetadata, $columnName); $fieldName = $this->_lookupFieldName($classMetadata, $columnName);
$cache[$key]['isScalar'] = false; $cache[$key]['isScalar'] = false;
// cache type information
$cache[$key]['type'] = $classMetadata->getTypeOfColumn($columnName);
} }
$cache[$key]['fieldName'] = $fieldName; $cache[$key]['fieldName'] = $fieldName;
// cache type information
$type = $classMetadata->getTypeOfColumn($columnName);
if ($type == 'integer' || $type == 'string') {
$cache[$key]['isSimpleType'] = true;
} else {
$cache[$key]['type'] = $type;
$cache[$key]['isSimpleType'] = false;
}
} }
$class = $this->_queryComponents[$cache[$key]['dqlAlias']]['metadata']; $class = $this->_queryComponents[$cache[$key]['dqlAlias']]['metadata'];
$dqlAlias = $cache[$key]['dqlAlias']; $dqlAlias = $cache[$key]['dqlAlias'];
$fieldName = $cache[$key]['fieldName']; $fieldName = $cache[$key]['fieldName'];
if ($cache[$key]['isSimpleType'] || $cache[$key]['isScalar']) { if ($cache[$key]['isScalar']) {
$rowData[$dqlAlias . '_' . $fieldName] = $value; $rowData[$dqlAlias . '_' . $fieldName] = $value;
} else { } else {
$rowData[$dqlAlias . '_' . $fieldName] = $this->prepareValue( $rowData[$dqlAlias . '_' . $fieldName] = $cache[$key]['type']->convertToPHPValue($value);
$class, $fieldName, $value, $cache[$key]['type']);
} }
//$rowData[$dqlAlias . '_' . $fieldName] = $cache[$key]['type']->convertToObjectValue($value);
} }
return $rowData; return $rowData;
...@@ -526,7 +507,7 @@ class Doctrine_ORM_Internal_Hydration_StandardHydrator extends Doctrine_ORM_Inte ...@@ -526,7 +507,7 @@ class Doctrine_ORM_Internal_Hydration_StandardHydrator extends Doctrine_ORM_Inte
* @return mixed prepared value * @return mixed prepared value
* @todo Remove. Should be handled by the Type classes. No need for this switch stuff. * @todo Remove. Should be handled by the Type classes. No need for this switch stuff.
*/ */
public function prepareValue(Doctrine_ClassMetadata $class, $fieldName, $value, $typeHint = null) public function prepareValue(Doctrine_ORM_Mapping_ClassMetadata $class, $fieldName, $value, $typeHint = null)
{ {
if ($value === $this->_nullObject) { if ($value === $this->_nullObject) {
return $this->_nullObject; return $this->_nullObject;
......
...@@ -617,7 +617,9 @@ class Doctrine_ORM_Mapping_ClassMetadata ...@@ -617,7 +617,9 @@ class Doctrine_ORM_Mapping_ClassMetadata
throw Doctrine_ORM_Exceptions_MappingException::missingType(); throw Doctrine_ORM_Exceptions_MappingException::missingType();
} }
$mapping['type'] = Doctrine_DBAL_Types_Type::getType($mapping['type']); if ( ! is_object($mapping['type'])) {
$mapping['type'] = Doctrine_DBAL_Types_Type::getType($mapping['type']);
}
// Complete fieldName and columnName mapping // Complete fieldName and columnName mapping
if ( ! isset($mapping['columnName'])) { if ( ! isset($mapping['columnName'])) {
......
...@@ -257,13 +257,12 @@ class Doctrine_ORM_UnitOfWork ...@@ -257,13 +257,12 @@ class Doctrine_ORM_UnitOfWork
/** /**
* Computes all the changes that have been done to entities in the identity map * Computes all the changes that have been done to entities in the identity map
* and stores these changes in _dataChangeSet temporarily for access by the * since the last commit and stores these changes in _dataChangeSet temporarily
* peristers, until the UoW commit is finished. * for access by the persisters, until the UoW commit is finished.
* *
* @param array $entities The entities for which to compute the changesets. If this * @param array $entities The entities for which to compute the changesets. If this
* parameter is not specified, the changesets of all entities in the identity * parameter is not specified, the changesets of all entities in the identity
* map are computed. * map are computed.
* @return void
*/ */
public function computeDataChangeSet(array $entities = null) public function computeDataChangeSet(array $entities = null)
{ {
...@@ -297,6 +296,7 @@ class Doctrine_ORM_UnitOfWork ...@@ -297,6 +296,7 @@ class Doctrine_ORM_UnitOfWork
if ($state == self::STATE_NEW) { if ($state == self::STATE_NEW) {
$this->_dataChangeSets[$oid] = $actualData; $this->_dataChangeSets[$oid] = $actualData;
$this->_originalEntityData[$oid] = $actualData;
} else { } else {
$originalData = $this->_originalEntityData[$oid]; $originalData = $this->_originalEntityData[$oid];
$changeSet = array(); $changeSet = array();
...@@ -308,13 +308,13 @@ class Doctrine_ORM_UnitOfWork ...@@ -308,13 +308,13 @@ class Doctrine_ORM_UnitOfWork
$changeSet[$propName] = array($orgValue => $actualValue); $changeSet[$propName] = array($orgValue => $actualValue);
} }
} }
$this->_dirtyEntities[$oid] = $entity; if ($changeSet) {
$this->_dataChangeSets[$oid] = $changeSet; $this->_dirtyEntities[$oid] = $entity;
$this->_dataChangeSets[$oid] = $changeSet;
$this->_originalEntityData[$oid] = $actualData;
}
} }
} }
if (isset($this->_dirtyEntities[$oid])) {
$this->_originalEntityData[$oid] = $actualData;
}
} }
} }
} }
...@@ -337,10 +337,11 @@ class Doctrine_ORM_UnitOfWork ...@@ -337,10 +337,11 @@ class Doctrine_ORM_UnitOfWork
$returnVal = $persister->insert($entity); $returnVal = $persister->insert($entity);
if ( ! is_null($returnVal)) { if ( ! is_null($returnVal)) {
$oid = spl_object_hash($entity); $oid = spl_object_hash($entity);
$class->getReflectionProperty($class->getSingleIdentifierFieldName()) $idField = $class->getSingleIdentifierFieldName();
->setValue($entity, $returnVal); $class->getReflectionProperty($idField)->setValue($entity, $returnVal);
$this->_entityIdentifiers[$oid] = array($returnVal); $this->_entityIdentifiers[$oid] = array($returnVal);
$this->_entityStates[$oid] = self::STATE_MANAGED; $this->_entityStates[$oid] = self::STATE_MANAGED;
$this->_originalEntityData[$oid][$idField] = $returnVal;
$this->addToIdentityMap($entity); $this->addToIdentityMap($entity);
} }
} }
...@@ -354,6 +355,7 @@ class Doctrine_ORM_UnitOfWork ...@@ -354,6 +355,7 @@ class Doctrine_ORM_UnitOfWork
*/ */
private function _executeUpdates($class) private function _executeUpdates($class)
{ {
try { throw new Exception(); } catch (Exception $e) { echo $e->getTraceAsString(); }
$className = $class->getClassName(); $className = $class->getClassName();
$persister = $this->_em->getEntityPersister($className); $persister = $this->_em->getEntityPersister($className);
foreach ($this->_dirtyEntities as $entity) { foreach ($this->_dirtyEntities as $entity) {
......
...@@ -12,7 +12,10 @@ class Orm_Functional_BasicCRUDTest extends Doctrine_OrmFunctionalTestCase { ...@@ -12,7 +12,10 @@ class Orm_Functional_BasicCRUDTest extends Doctrine_OrmFunctionalTestCase {
$em = $this->_getEntityManager(); $em = $this->_getEntityManager();
$exporter = new Doctrine_ORM_Export_ClassExporter($em); $exporter = new Doctrine_ORM_Export_ClassExporter($em);
$exporter->exportClasses(array($em->getClassMetadata('CmsUser'))); $exporter->exportClasses(array(
$em->getClassMetadata('CmsUser'),
$em->getClassMetadata('CmsPhonenumber')
));
// Create // Create
$user = new CmsUser; $user = new CmsUser;
...@@ -33,6 +36,13 @@ class Orm_Functional_BasicCRUDTest extends Doctrine_OrmFunctionalTestCase { ...@@ -33,6 +36,13 @@ class Orm_Functional_BasicCRUDTest extends Doctrine_OrmFunctionalTestCase {
$user4 = $em->find('CmsUser', $user2->id); $user4 = $em->find('CmsUser', $user2->id);
$this->assertTrue($user2 === $user4); $this->assertTrue($user2 === $user4);
$ph = new CmsPhonenumber;
$ph->phonenumber = "12345";
$user->phonenumbers[] = $ph;
//var_dump($em->getUnitOfWork())
} }
} }
...@@ -21,7 +21,7 @@ class Orm_Mapping_ClassMetadataFactoryTest extends Doctrine_OrmTestCase { ...@@ -21,7 +21,7 @@ class Orm_Mapping_ClassMetadataFactoryTest extends Doctrine_OrmTestCase {
// Self-made metadata // Self-made metadata
$cm1 = new Doctrine_ORM_Mapping_ClassMetadata('CMFTest_Entity1'); $cm1 = new Doctrine_ORM_Mapping_ClassMetadata('CMFTest_Entity1');
// Add a mapped field // Add a mapped field
$cm1->mapField(array('fieldName' => 'name', 'type' => 'string')); $cm1->mapField(array('fieldName' => 'name', 'type' => 'varchar'));
// and a mapped association // and a mapped association
$cm1->mapOneToOne(array('fieldName' => 'other', 'targetEntity' => 'Other', 'mappedBy' => 'this')); $cm1->mapOneToOne(array('fieldName' => 'other', 'targetEntity' => 'Other', 'mappedBy' => 'this'));
// and an id generator type // and an id generator type
...@@ -56,7 +56,7 @@ class Orm_Mapping_ClassMetadataFactoryTest extends Doctrine_OrmTestCase { ...@@ -56,7 +56,7 @@ class Orm_Mapping_ClassMetadataFactoryTest extends Doctrine_OrmTestCase {
$cm1 = new Doctrine_ORM_Mapping_ClassMetadata('CMFTest_Entity1'); $cm1 = new Doctrine_ORM_Mapping_ClassMetadata('CMFTest_Entity1');
$cm1->setInheritanceType('singleTable'); $cm1->setInheritanceType('singleTable');
// Add a mapped field // Add a mapped field
$cm1->mapField(array('fieldName' => 'name', 'type' => 'string')); $cm1->mapField(array('fieldName' => 'name', 'type' => 'varchar'));
// and a mapped association // and a mapped association
$cm1->mapOneToOne(array('fieldName' => 'other', 'targetEntity' => 'Other', 'mappedBy' => 'this')); $cm1->mapOneToOne(array('fieldName' => 'other', 'targetEntity' => 'Other', 'mappedBy' => 'this'));
// and an id generator type // and an id generator type
......
...@@ -26,7 +26,7 @@ class CmsUser ...@@ -26,7 +26,7 @@ class CmsUser
*/ */
public $name; public $name;
/** /**
* @DoctrineOneToMany(targetEntity="CmsPhonenumber", mappedBy="user") * @DoctrineOneToMany(targetEntity="CmsPhonenumber", mappedBy="user", cascade={"save"})
*/ */
public $phonenumbers; public $phonenumbers;
/** /**
......
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