fixed regression
This commit is contained in:
parent
d97336373d
commit
b6e385d243
@ -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_map(array($this->_conn, 'quoteIdentifier'), $keyColumns);
|
||||
$keyColumns = array_map(array($this, 'quoteIdentifier'), $keyColumns);
|
||||
$queryFields.= ', PRIMARY KEY('.implode(', ', $keyColumns).')';
|
||||
}
|
||||
|
||||
|
@ -48,9 +48,14 @@ abstract class Doctrine_DBAL_Types_Type
|
||||
*/
|
||||
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::$_typesMap[$name])) {
|
||||
throw Doctrine_Exception::unknownType($name);
|
||||
throw new Doctrine_Exception("Unknown type: $name");
|
||||
}
|
||||
self::$_typeObjects[$name] = new self::$_typesMap[$name]();
|
||||
}
|
||||
|
@ -71,6 +71,7 @@ class Doctrine_ORM_Export_ClassExporter
|
||||
$column['length'] = $mapping['length'];
|
||||
|
||||
if ($class->isIdentifier($fieldName)) {
|
||||
$column['primary'] = true;
|
||||
if ($class->isIdGeneratorIdentity()) {
|
||||
$column['autoincrement'] = true;
|
||||
}
|
||||
|
@ -327,6 +327,8 @@ class Doctrine_ORM_Internal_Hydration_StandardHydrator extends Doctrine_ORM_Inte
|
||||
} else {
|
||||
$fieldName = $this->_lookupFieldName($classMetadata, $columnName);
|
||||
$cache[$key]['isScalar'] = false;
|
||||
// cache type information
|
||||
$cache[$key]['type'] = $classMetadata->getTypeOfColumn($columnName);
|
||||
}
|
||||
|
||||
$cache[$key]['fieldName'] = $fieldName;
|
||||
@ -337,15 +339,6 @@ class Doctrine_ORM_Internal_Hydration_StandardHydrator extends Doctrine_ORM_Inte
|
||||
} else {
|
||||
$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'];
|
||||
@ -361,13 +354,11 @@ class Doctrine_ORM_Internal_Hydration_StandardHydrator extends Doctrine_ORM_Inte
|
||||
$id[$dqlAlias] .= '|' . $value;
|
||||
}
|
||||
|
||||
if ($cache[$key]['isSimpleType']) {
|
||||
if ($cache[$key]['isScalar']) {
|
||||
$rowData[$dqlAlias][$fieldName] = $value;
|
||||
} else {
|
||||
$rowData[$dqlAlias][$fieldName] = $this->prepareValue(
|
||||
$class, $fieldName, $value, $cache[$key]['type']);
|
||||
$rowData[$dqlAlias][$fieldName] = $cache[$key]['type']->convertToPHPValue($value);
|
||||
}
|
||||
//$rowData[$dqlAlias][$fieldName] = $cache[$key]['type']->convertToObjectValue($value);
|
||||
|
||||
if ( ! isset($nonemptyComponents[$dqlAlias]) && $value !== null) {
|
||||
$nonemptyComponents[$dqlAlias] = true;
|
||||
@ -412,31 +403,21 @@ class Doctrine_ORM_Internal_Hydration_StandardHydrator extends Doctrine_ORM_Inte
|
||||
} else {
|
||||
$fieldName = $this->_lookupFieldName($classMetadata, $columnName);
|
||||
$cache[$key]['isScalar'] = false;
|
||||
// cache type information
|
||||
$cache[$key]['type'] = $classMetadata->getTypeOfColumn($columnName);
|
||||
}
|
||||
|
||||
$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'];
|
||||
$dqlAlias = $cache[$key]['dqlAlias'];
|
||||
$fieldName = $cache[$key]['fieldName'];
|
||||
|
||||
if ($cache[$key]['isSimpleType'] || $cache[$key]['isScalar']) {
|
||||
if ($cache[$key]['isScalar']) {
|
||||
$rowData[$dqlAlias . '_' . $fieldName] = $value;
|
||||
} else {
|
||||
$rowData[$dqlAlias . '_' . $fieldName] = $this->prepareValue(
|
||||
$class, $fieldName, $value, $cache[$key]['type']);
|
||||
$rowData[$dqlAlias . '_' . $fieldName] = $cache[$key]['type']->convertToPHPValue($value);
|
||||
}
|
||||
//$rowData[$dqlAlias . '_' . $fieldName] = $cache[$key]['type']->convertToObjectValue($value);
|
||||
}
|
||||
|
||||
return $rowData;
|
||||
@ -526,7 +507,7 @@ class Doctrine_ORM_Internal_Hydration_StandardHydrator extends Doctrine_ORM_Inte
|
||||
* @return mixed prepared value
|
||||
* @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) {
|
||||
return $this->_nullObject;
|
||||
|
@ -617,7 +617,9 @@ class Doctrine_ORM_Mapping_ClassMetadata
|
||||
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
|
||||
if ( ! isset($mapping['columnName'])) {
|
||||
|
@ -257,13 +257,12 @@ class Doctrine_ORM_UnitOfWork
|
||||
|
||||
/**
|
||||
* 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
|
||||
* peristers, until the UoW commit is finished.
|
||||
* since the last commit and stores these changes in _dataChangeSet temporarily
|
||||
* for access by the persisters, until the UoW commit is finished.
|
||||
*
|
||||
* @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
|
||||
* map are computed.
|
||||
* @return void
|
||||
*/
|
||||
public function computeDataChangeSet(array $entities = null)
|
||||
{
|
||||
@ -297,6 +296,7 @@ class Doctrine_ORM_UnitOfWork
|
||||
|
||||
if ($state == self::STATE_NEW) {
|
||||
$this->_dataChangeSets[$oid] = $actualData;
|
||||
$this->_originalEntityData[$oid] = $actualData;
|
||||
} else {
|
||||
$originalData = $this->_originalEntityData[$oid];
|
||||
$changeSet = array();
|
||||
@ -308,13 +308,13 @@ class Doctrine_ORM_UnitOfWork
|
||||
$changeSet[$propName] = array($orgValue => $actualValue);
|
||||
}
|
||||
}
|
||||
$this->_dirtyEntities[$oid] = $entity;
|
||||
$this->_dataChangeSets[$oid] = $changeSet;
|
||||
if ($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
|
||||
$returnVal = $persister->insert($entity);
|
||||
if ( ! is_null($returnVal)) {
|
||||
$oid = spl_object_hash($entity);
|
||||
$class->getReflectionProperty($class->getSingleIdentifierFieldName())
|
||||
->setValue($entity, $returnVal);
|
||||
$idField = $class->getSingleIdentifierFieldName();
|
||||
$class->getReflectionProperty($idField)->setValue($entity, $returnVal);
|
||||
$this->_entityIdentifiers[$oid] = array($returnVal);
|
||||
$this->_entityStates[$oid] = self::STATE_MANAGED;
|
||||
$this->_originalEntityData[$oid][$idField] = $returnVal;
|
||||
$this->addToIdentityMap($entity);
|
||||
}
|
||||
}
|
||||
@ -354,6 +355,7 @@ class Doctrine_ORM_UnitOfWork
|
||||
*/
|
||||
private function _executeUpdates($class)
|
||||
{
|
||||
try { throw new Exception(); } catch (Exception $e) { echo $e->getTraceAsString(); }
|
||||
$className = $class->getClassName();
|
||||
$persister = $this->_em->getEntityPersister($className);
|
||||
foreach ($this->_dirtyEntities as $entity) {
|
||||
|
@ -12,7 +12,10 @@ class Orm_Functional_BasicCRUDTest extends Doctrine_OrmFunctionalTestCase {
|
||||
$em = $this->_getEntityManager();
|
||||
|
||||
$exporter = new Doctrine_ORM_Export_ClassExporter($em);
|
||||
$exporter->exportClasses(array($em->getClassMetadata('CmsUser')));
|
||||
$exporter->exportClasses(array(
|
||||
$em->getClassMetadata('CmsUser'),
|
||||
$em->getClassMetadata('CmsPhonenumber')
|
||||
));
|
||||
|
||||
// Create
|
||||
$user = new CmsUser;
|
||||
@ -33,6 +36,13 @@ class Orm_Functional_BasicCRUDTest extends Doctrine_OrmFunctionalTestCase {
|
||||
|
||||
$user4 = $em->find('CmsUser', $user2->id);
|
||||
$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 {
|
||||
// Self-made metadata
|
||||
$cm1 = new Doctrine_ORM_Mapping_ClassMetadata('CMFTest_Entity1');
|
||||
// Add a mapped field
|
||||
$cm1->mapField(array('fieldName' => 'name', 'type' => 'string'));
|
||||
$cm1->mapField(array('fieldName' => 'name', 'type' => 'varchar'));
|
||||
// and a mapped association
|
||||
$cm1->mapOneToOne(array('fieldName' => 'other', 'targetEntity' => 'Other', 'mappedBy' => 'this'));
|
||||
// and an id generator type
|
||||
@ -56,7 +56,7 @@ class Orm_Mapping_ClassMetadataFactoryTest extends Doctrine_OrmTestCase {
|
||||
$cm1 = new Doctrine_ORM_Mapping_ClassMetadata('CMFTest_Entity1');
|
||||
$cm1->setInheritanceType('singleTable');
|
||||
// Add a mapped field
|
||||
$cm1->mapField(array('fieldName' => 'name', 'type' => 'string'));
|
||||
$cm1->mapField(array('fieldName' => 'name', 'type' => 'varchar'));
|
||||
// and a mapped association
|
||||
$cm1->mapOneToOne(array('fieldName' => 'other', 'targetEntity' => 'Other', 'mappedBy' => 'this'));
|
||||
// and an id generator type
|
||||
|
@ -26,7 +26,7 @@ class CmsUser
|
||||
*/
|
||||
public $name;
|
||||
/**
|
||||
* @DoctrineOneToMany(targetEntity="CmsPhonenumber", mappedBy="user")
|
||||
* @DoctrineOneToMany(targetEntity="CmsPhonenumber", mappedBy="user", cascade={"save"})
|
||||
*/
|
||||
public $phonenumbers;
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user