1
0
mirror of synced 2025-02-03 05:49:25 +03:00

Merge pull request #1545 from doctrine/general-fixes

[RFC] General fixes
This commit is contained in:
Marco Pivetta 2015-11-06 22:56:00 -05:00
commit 378f6546b4
54 changed files with 609 additions and 395 deletions

View File

@ -29,7 +29,5 @@ matrix:
exclude: exclude:
- php: hhvm - php: hhvm
env: DB=pgsql # driver for PostgreSQL currently unsupported by HHVM, requires 3rd party dependency env: DB=pgsql # driver for PostgreSQL currently unsupported by HHVM, requires 3rd party dependency
allow_failures:
- php: 7.0
sudo: false sudo: false

View File

@ -76,7 +76,6 @@ class DefaultEntityHydrator implements EntityHydrator
$data = array_merge($data, $key->identifier); // why update has no identifier values ? $data = array_merge($data, $key->identifier); // why update has no identifier values ?
foreach ($metadata->associationMappings as $name => $assoc) { foreach ($metadata->associationMappings as $name => $assoc) {
if ( ! isset($data[$name])) { if ( ! isset($data[$name])) {
continue; continue;
} }
@ -92,18 +91,16 @@ class DefaultEntityHydrator implements EntityHydrator
unset($data[$name]); unset($data[$name]);
foreach ($associationIds as $fieldName => $fieldValue) { foreach ($associationIds as $fieldName => $fieldValue) {
if (isset($targetClassMetadata->associationMappings[$fieldName])){ if (isset($targetClassMetadata->associationMappings[$fieldName])){
$targetAssoc = $targetClassMetadata->associationMappings[$fieldName]; $targetAssoc = $targetClassMetadata->associationMappings[$fieldName];
foreach($assoc['targetToSourceKeyColumns'] as $referencedColumn => $localColumn) { foreach($assoc['targetToSourceKeyColumns'] as $referencedColumn => $localColumn) {
if (isset($targetAssoc['sourceToTargetKeyColumns'][$referencedColumn])) { if (isset($targetAssoc['sourceToTargetKeyColumns'][$referencedColumn])) {
$data[$localColumn] = $fieldValue; $data[$localColumn] = $fieldValue;
} }
} }
}else{ } else {
$data[$assoc['targetToSourceKeyColumns'][$targetClassMetadata->columnNames[$fieldName]]] = $fieldValue; $data[$assoc['targetToSourceKeyColumns'][$targetClassMetadata->fieldMappings[$fieldName]['columnName']]] = $fieldValue;
} }
} }
@ -126,7 +123,6 @@ class DefaultEntityHydrator implements EntityHydrator
// @TODO - fix it ! // @TODO - fix it !
// handle UnitOfWork#createEntity hash generation // handle UnitOfWork#createEntity hash generation
if ( ! is_array($targetId)) { if ( ! is_array($targetId)) {
$data[reset($assoc['joinColumnFieldNames'])] = $targetId; $data[reset($assoc['joinColumnFieldNames'])] = $targetId;
$targetEntity = $this->em->getClassMetadata($assoc['targetEntity']); $targetEntity = $this->em->getClassMetadata($assoc['targetEntity']);

View File

@ -120,6 +120,7 @@ abstract class AbstractHydrator
$this->_hints = $hints; $this->_hints = $hints;
$evm = $this->_em->getEventManager(); $evm = $this->_em->getEventManager();
$evm->addEventListener(array(Events::onClear), $this); $evm->addEventListener(array(Events::onClear), $this);
$this->prepare(); $this->prepare();
@ -400,11 +401,13 @@ abstract class AbstractHydrator
// Meta column (has meaning in relational schema only, i.e. foreign keys or discriminator columns). // Meta column (has meaning in relational schema only, i.e. foreign keys or discriminator columns).
$fieldName = $this->_rsm->metaMappings[$key]; $fieldName = $this->_rsm->metaMappings[$key];
$dqlAlias = $this->_rsm->columnOwnerMap[$key]; $dqlAlias = $this->_rsm->columnOwnerMap[$key];
$classMetadata = $this->getClassMetadata($this->_rsm->aliasMap[$dqlAlias]);
$type = isset($this->_rsm->typeMappings[$key]) $type = isset($this->_rsm->typeMappings[$key])
? Type::getType($this->_rsm->typeMappings[$key]) ? Type::getType($this->_rsm->typeMappings[$key])
: null; : null;
// Cache metadata fetch
$this->getClassMetadata($this->_rsm->aliasMap[$dqlAlias]);
return $this->_cache[$key] = array( return $this->_cache[$key] = array(
'isIdentifier' => isset($this->_rsm->isIdentifierColumn[$dqlAlias][$key]), 'isIdentifier' => isset($this->_rsm->isIdentifierColumn[$dqlAlias][$key]),
'isMetaColumn' => true, 'isMetaColumn' => true,

View File

@ -399,7 +399,6 @@ class ClassMetadataInfo implements ClassMetadata
/** /**
* READ-ONLY: An array of field names. Used to look up field names from column names. * READ-ONLY: An array of field names. Used to look up field names from column names.
* Keys are column names and values are field names. * Keys are column names and values are field names.
* This is the reverse lookup map of $_columnNames.
* *
* @var array * @var array
*/ */
@ -412,7 +411,7 @@ class ClassMetadataInfo implements ClassMetadata
* *
* @var array * @var array
* *
* @todo We could get rid of this array by just using $fieldMappings[$fieldName]['columnName']. * @deprecated 3.0 Remove this.
*/ */
public $columnNames = array(); public $columnNames = array();
@ -742,7 +741,7 @@ class ClassMetadataInfo implements ClassMetadata
* Populates the entity identifier of an entity. * Populates the entity identifier of an entity.
* *
* @param object $entity * @param object $entity
* @param mixed $id * @param array $id
* *
* @return void * @return void
* *
@ -812,7 +811,7 @@ class ClassMetadataInfo implements ClassMetadata
// This metadata is always serialized/cached. // This metadata is always serialized/cached.
$serialized = array( $serialized = array(
'associationMappings', 'associationMappings',
'columnNames', //TODO: Not really needed. Can use fieldMappings[$fieldName]['columnName'] 'columnNames', //TODO: 3.0 Remove this. Can use fieldMappings[$fieldName]['columnName']
'fieldMappings', 'fieldMappings',
'fieldNames', 'fieldNames',
'embeddedClasses', 'embeddedClasses',
@ -1177,9 +1176,11 @@ class ClassMetadataInfo implements ClassMetadata
public function isUniqueField($fieldName) public function isUniqueField($fieldName)
{ {
$mapping = $this->getFieldMapping($fieldName); $mapping = $this->getFieldMapping($fieldName);
if ($mapping !== false) { if ($mapping !== false) {
return isset($mapping['unique']) && $mapping['unique'] == true; return isset($mapping['unique']) && $mapping['unique'] == true;
} }
return false; return false;
} }
@ -1193,9 +1194,11 @@ class ClassMetadataInfo implements ClassMetadata
public function isNullable($fieldName) public function isNullable($fieldName)
{ {
$mapping = $this->getFieldMapping($fieldName); $mapping = $this->getFieldMapping($fieldName);
if ($mapping !== false) { if ($mapping !== false) {
return isset($mapping['nullable']) && $mapping['nullable'] == true; return isset($mapping['nullable']) && $mapping['nullable'] == true;
} }
return false; return false;
} }
@ -1210,8 +1213,9 @@ class ClassMetadataInfo implements ClassMetadata
*/ */
public function getColumnName($fieldName) public function getColumnName($fieldName)
{ {
return isset($this->columnNames[$fieldName]) ? return isset($this->columnNames[$fieldName])
$this->columnNames[$fieldName] : $fieldName; ? $this->columnNames[$fieldName]
: $fieldName;
} }
/** /**
@ -1229,6 +1233,7 @@ class ClassMetadataInfo implements ClassMetadata
if ( ! isset($this->fieldMappings[$fieldName])) { if ( ! isset($this->fieldMappings[$fieldName])) {
throw MappingException::mappingNotFound($this->name, $fieldName); throw MappingException::mappingNotFound($this->name, $fieldName);
} }
return $this->fieldMappings[$fieldName]; return $this->fieldMappings[$fieldName];
} }
@ -1249,6 +1254,7 @@ class ClassMetadataInfo implements ClassMetadata
if ( ! isset($this->associationMappings[$fieldName])) { if ( ! isset($this->associationMappings[$fieldName])) {
throw MappingException::mappingNotFound($this->name, $fieldName); throw MappingException::mappingNotFound($this->name, $fieldName);
} }
return $this->associationMappings[$fieldName]; return $this->associationMappings[$fieldName];
} }
@ -1272,8 +1278,9 @@ class ClassMetadataInfo implements ClassMetadata
*/ */
public function getFieldName($columnName) public function getFieldName($columnName)
{ {
return isset($this->fieldNames[$columnName]) ? return isset($this->fieldNames[$columnName])
$this->fieldNames[$columnName] : $columnName; ? $this->fieldNames[$columnName]
: $columnName;
} }
/** /**
@ -1292,6 +1299,7 @@ class ClassMetadataInfo implements ClassMetadata
if ( ! isset($this->namedQueries[$queryName])) { if ( ! isset($this->namedQueries[$queryName])) {
throw MappingException::queryNotFound($this->name, $queryName); throw MappingException::queryNotFound($this->name, $queryName);
} }
return $this->namedQueries[$queryName]['dql']; return $this->namedQueries[$queryName]['dql'];
} }
@ -1380,6 +1388,7 @@ class ClassMetadataInfo implements ClassMetadata
if ( ! isset($mapping['fieldName']) || strlen($mapping['fieldName']) == 0) { if ( ! isset($mapping['fieldName']) || strlen($mapping['fieldName']) == 0) {
throw MappingException::missingFieldName($this->name); throw MappingException::missingFieldName($this->name);
} }
if ( ! isset($mapping['type'])) { if ( ! isset($mapping['type'])) {
// Default to string // Default to string
$mapping['type'] = 'string'; $mapping['type'] = 'string';
@ -1396,6 +1405,7 @@ class ClassMetadataInfo implements ClassMetadata
} }
$this->columnNames[$mapping['fieldName']] = $mapping['columnName']; $this->columnNames[$mapping['fieldName']] = $mapping['columnName'];
if (isset($this->fieldNames[$mapping['columnName']]) || ($this->discriminatorColumn != null && $this->discriminatorColumn['name'] == $mapping['columnName'])) { if (isset($this->fieldNames[$mapping['columnName']]) || ($this->discriminatorColumn != null && $this->discriminatorColumn['name'] == $mapping['columnName'])) {
throw MappingException::duplicateColumnName($this->name, $mapping['columnName']); throw MappingException::duplicateColumnName($this->name, $mapping['columnName']);
} }
@ -1411,6 +1421,7 @@ class ClassMetadataInfo implements ClassMetadata
if ( ! in_array($mapping['fieldName'], $this->identifier)) { if ( ! in_array($mapping['fieldName'], $this->identifier)) {
$this->identifier[] = $mapping['fieldName']; $this->identifier[] = $mapping['fieldName'];
} }
// Check for composite key // Check for composite key
if ( ! $this->isIdentifierComposite && count($this->identifier) > 1) { if ( ! $this->isIdentifierComposite && count($this->identifier) > 1) {
$this->isIdentifierComposite = true; $this->isIdentifierComposite = true;
@ -1441,9 +1452,11 @@ class ClassMetadataInfo implements ClassMetadata
if ( ! isset($mapping['mappedBy'])) { if ( ! isset($mapping['mappedBy'])) {
$mapping['mappedBy'] = null; $mapping['mappedBy'] = null;
} }
if ( ! isset($mapping['inversedBy'])) { if ( ! isset($mapping['inversedBy'])) {
$mapping['inversedBy'] = null; $mapping['inversedBy'] = null;
} }
$mapping['isOwningSide'] = true; // assume owning side until we hit mappedBy $mapping['isOwningSide'] = true; // assume owning side until we hit mappedBy
// unset optional indexBy attribute if its empty // unset optional indexBy attribute if its empty
@ -1460,10 +1473,7 @@ class ClassMetadataInfo implements ClassMetadata
$mapping['targetEntity'] = ltrim($mapping['targetEntity'], '\\'); $mapping['targetEntity'] = ltrim($mapping['targetEntity'], '\\');
} }
if ( ($mapping['type'] & self::MANY_TO_ONE) > 0 && if (($mapping['type'] & self::MANY_TO_ONE) > 0 && isset($mapping['orphanRemoval']) && $mapping['orphanRemoval'] == true) {
isset($mapping['orphanRemoval']) &&
$mapping['orphanRemoval'] == true) {
throw MappingException::illegalOrphanRemoval($this->name, $mapping['fieldName']); throw MappingException::illegalOrphanRemoval($this->name, $mapping['fieldName']);
} }
@ -1483,6 +1493,7 @@ class ClassMetadataInfo implements ClassMetadata
$this->identifier[] = $mapping['fieldName']; $this->identifier[] = $mapping['fieldName'];
$this->containsForeignIdentifier = true; $this->containsForeignIdentifier = true;
} }
// Check for composite key // Check for composite key
if ( ! $this->isIdentifierComposite && count($this->identifier) > 1) { if ( ! $this->isIdentifierComposite && count($this->identifier) > 1) {
$this->isIdentifierComposite = true; $this->isIdentifierComposite = true;
@ -1498,6 +1509,7 @@ class ClassMetadataInfo implements ClassMetadata
if ( ! isset($mapping['fieldName']) || strlen($mapping['fieldName']) == 0) { if ( ! isset($mapping['fieldName']) || strlen($mapping['fieldName']) == 0) {
throw MappingException::missingFieldName($this->name); throw MappingException::missingFieldName($this->name);
} }
if ( ! isset($mapping['targetEntity'])) { if ( ! isset($mapping['targetEntity'])) {
throw MappingException::missingTargetEntity($mapping['fieldName']); throw MappingException::missingTargetEntity($mapping['fieldName']);
} }
@ -1569,13 +1581,16 @@ class ClassMetadataInfo implements ClassMetadata
if ($mapping['isOwningSide']) { if ($mapping['isOwningSide']) {
if ( ! isset($mapping['joinColumns']) || ! $mapping['joinColumns']) { if ( ! isset($mapping['joinColumns']) || ! $mapping['joinColumns']) {
// Apply default join column // Apply default join column
$mapping['joinColumns'] = array(array( $mapping['joinColumns'] = array(
array(
'name' => $this->namingStrategy->joinColumnName($mapping['fieldName'], $this->name), 'name' => $this->namingStrategy->joinColumnName($mapping['fieldName'], $this->name),
'referencedColumnName' => $this->namingStrategy->referenceColumnName() 'referencedColumnName' => $this->namingStrategy->referenceColumnName()
)); )
);
} }
$uniqueConstraintColumns = array(); $uniqueConstraintColumns = array();
foreach ($mapping['joinColumns'] as &$joinColumn) { foreach ($mapping['joinColumns'] as &$joinColumn) {
if ($mapping['type'] === self::ONE_TO_ONE && ! $this->isInheritanceTypeSingleTable()) { if ($mapping['type'] === self::ONE_TO_ONE && ! $this->isInheritanceTypeSingleTable()) {
if (count($mapping['joinColumns']) == 1) { if (count($mapping['joinColumns']) == 1) {
@ -1607,14 +1622,16 @@ class ClassMetadataInfo implements ClassMetadata
$mapping['sourceToTargetKeyColumns'][$joinColumn['name']] = $joinColumn['referencedColumnName']; $mapping['sourceToTargetKeyColumns'][$joinColumn['name']] = $joinColumn['referencedColumnName'];
$mapping['joinColumnFieldNames'][$joinColumn['name']] = isset($joinColumn['fieldName']) $mapping['joinColumnFieldNames'][$joinColumn['name']] = isset($joinColumn['fieldName'])
? $joinColumn['fieldName'] : $joinColumn['name']; ? $joinColumn['fieldName']
: $joinColumn['name'];
} }
if ($uniqueConstraintColumns) { if ($uniqueConstraintColumns) {
if ( ! $this->table) { if ( ! $this->table) {
throw new RuntimeException("ClassMetadataInfo::setTable() has to be called before defining a one to one relationship."); throw new RuntimeException("ClassMetadataInfo::setTable() has to be called before defining a one to one relationship.");
} }
$this->table['uniqueConstraints'][$mapping['fieldName']."_uniq"] = array(
$this->table['uniqueConstraints'][$mapping['fieldName'] . "_uniq"] = array(
'columns' => $uniqueConstraintColumns 'columns' => $uniqueConstraintColumns
); );
} }
@ -1679,6 +1696,7 @@ class ClassMetadataInfo implements ClassMetadata
protected function _validateAndCompleteManyToManyMapping(array $mapping) protected function _validateAndCompleteManyToManyMapping(array $mapping)
{ {
$mapping = $this->_validateAndCompleteAssociationMapping($mapping); $mapping = $this->_validateAndCompleteAssociationMapping($mapping);
if ($mapping['isOwningSide']) { if ($mapping['isOwningSide']) {
// owning side MUST have a join table // owning side MUST have a join table
if ( ! isset($mapping['joinTable']['name'])) { if ( ! isset($mapping['joinTable']['name'])) {
@ -1689,16 +1707,23 @@ class ClassMetadataInfo implements ClassMetadata
&& (! (isset($mapping['joinTable']['joinColumns']) || isset($mapping['joinTable']['inverseJoinColumns']))); && (! (isset($mapping['joinTable']['joinColumns']) || isset($mapping['joinTable']['inverseJoinColumns'])));
if ( ! isset($mapping['joinTable']['joinColumns'])) { if ( ! isset($mapping['joinTable']['joinColumns'])) {
$mapping['joinTable']['joinColumns'] = array(array( $mapping['joinTable']['joinColumns'] = array(
array(
'name' => $this->namingStrategy->joinKeyColumnName($mapping['sourceEntity'], $selfReferencingEntityWithoutJoinColumns ? 'source' : null), 'name' => $this->namingStrategy->joinKeyColumnName($mapping['sourceEntity'], $selfReferencingEntityWithoutJoinColumns ? 'source' : null),
'referencedColumnName' => $this->namingStrategy->referenceColumnName(), 'referencedColumnName' => $this->namingStrategy->referenceColumnName(),
'onDelete' => 'CASCADE')); 'onDelete' => 'CASCADE'
)
);
} }
if ( ! isset($mapping['joinTable']['inverseJoinColumns'])) { if ( ! isset($mapping['joinTable']['inverseJoinColumns'])) {
$mapping['joinTable']['inverseJoinColumns'] = array(array( $mapping['joinTable']['inverseJoinColumns'] = array(
array(
'name' => $this->namingStrategy->joinKeyColumnName($mapping['targetEntity'], $selfReferencingEntityWithoutJoinColumns ? 'target' : null), 'name' => $this->namingStrategy->joinKeyColumnName($mapping['targetEntity'], $selfReferencingEntityWithoutJoinColumns ? 'target' : null),
'referencedColumnName' => $this->namingStrategy->referenceColumnName(), 'referencedColumnName' => $this->namingStrategy->referenceColumnName(),
'onDelete' => 'CASCADE')); 'onDelete' => 'CASCADE'
)
);
} }
$mapping['joinTableColumns'] = array(); $mapping['joinTableColumns'] = array();
@ -1790,6 +1815,7 @@ class ClassMetadataInfo implements ClassMetadata
if ($this->isIdentifierComposite) { if ($this->isIdentifierComposite) {
throw MappingException::singleIdNotAllowedOnCompositePrimaryKey($this->name); throw MappingException::singleIdNotAllowedOnCompositePrimaryKey($this->name);
} }
return $this->identifier[0]; return $this->identifier[0];
} }
@ -1848,14 +1874,16 @@ class ClassMetadataInfo implements ClassMetadata
{ {
if ($fieldNames === null) { if ($fieldNames === null) {
return array_keys($this->fieldNames); return array_keys($this->fieldNames);
} else { }
$columnNames = array(); $columnNames = array();
foreach ($fieldNames as $fieldName) { foreach ($fieldNames as $fieldName) {
$columnNames[] = $this->getColumnName($fieldName); $columnNames[] = $this->getColumnName($fieldName);
} }
return $columnNames; return $columnNames;
} }
}
/** /**
* Returns an array with all the identifier column names. * Returns an array with all the identifier column names.
@ -2003,11 +2031,14 @@ class ClassMetadataInfo implements ClassMetadata
* @param string $fieldName * @param string $fieldName
* *
* @return \Doctrine\DBAL\Types\Type|string|null * @return \Doctrine\DBAL\Types\Type|string|null
*
* @todo 3.0 Remove this. PersisterHelper should fix it somehow
*/ */
public function getTypeOfField($fieldName) public function getTypeOfField($fieldName)
{ {
return isset($this->fieldMappings[$fieldName]) ? return isset($this->fieldMappings[$fieldName])
$this->fieldMappings[$fieldName]['type'] : null; ? $this->fieldMappings[$fieldName]['type']
: null;
} }
/** /**
@ -2017,8 +2048,8 @@ class ClassMetadataInfo implements ClassMetadata
* *
* @return \Doctrine\DBAL\Types\Type|string|null * @return \Doctrine\DBAL\Types\Type|string|null
* *
* @deprecated this method is bogous and unreliable, since it cannot resolve the type of a column that is * @deprecated 3.0 remove this. this method is bogous and unreliable, since it cannot resolve the type of a column
* derived by a referenced field on a different entity. * that is derived by a referenced field on a different entity.
*/ */
public function getTypeOfColumn($columnName) public function getTypeOfColumn($columnName)
{ {
@ -2082,6 +2113,7 @@ class ClassMetadataInfo implements ClassMetadata
public function setParentClasses(array $classNames) public function setParentClasses(array $classNames)
{ {
$this->parentClasses = $classNames; $this->parentClasses = $classNames;
if (count($classNames) > 0) { if (count($classNames) > 0) {
$this->rootEntityName = array_pop($classNames); $this->rootEntityName = array_pop($classNames);
} }
@ -2101,6 +2133,7 @@ class ClassMetadataInfo implements ClassMetadata
if ( ! $this->_isInheritanceType($type)) { if ( ! $this->_isInheritanceType($type)) {
throw MappingException::invalidInheritanceType($this->name, $type); throw MappingException::invalidInheritanceType($this->name, $type);
} }
$this->inheritanceType = $type; $this->inheritanceType = $type;
} }
@ -2195,6 +2228,7 @@ class ClassMetadataInfo implements ClassMetadata
unset($this->fieldMappings[$fieldName]); unset($this->fieldMappings[$fieldName]);
unset($this->fieldNames[$mapping['columnName']]); unset($this->fieldNames[$mapping['columnName']]);
unset($this->columnNames[$mapping['fieldName']]); unset($this->columnNames[$mapping['fieldName']]);
$this->_validateAndCompleteFieldMapping($overrideMapping); $this->_validateAndCompleteFieldMapping($overrideMapping);
$this->fieldMappings[$fieldName] = $overrideMapping; $this->fieldMappings[$fieldName] = $overrideMapping;
@ -2394,10 +2428,11 @@ class ClassMetadataInfo implements ClassMetadata
$name = $queryMapping['name']; $name = $queryMapping['name'];
$query = $queryMapping['query']; $query = $queryMapping['query'];
$dql = str_replace('__CLASS__', $this->name, $query); $dql = str_replace('__CLASS__', $this->name, $query);
$this->namedQueries[$name] = array( $this->namedQueries[$name] = array(
'name' => $name, 'name' => $name,
'query' => $query, 'query' => $query,
'dql' => $dql 'dql' => $dql,
); );
} }
@ -2430,8 +2465,8 @@ class ClassMetadataInfo implements ClassMetadata
} }
$queryMapping['isSelfClass'] = false; $queryMapping['isSelfClass'] = false;
if (isset($queryMapping['resultClass'])) {
if (isset($queryMapping['resultClass'])) {
if ($queryMapping['resultClass'] === '__CLASS__') { if ($queryMapping['resultClass'] === '__CLASS__') {
$queryMapping['isSelfClass'] = true; $queryMapping['isSelfClass'] = true;
@ -2516,7 +2551,9 @@ class ClassMetadataInfo implements ClassMetadata
public function mapOneToOne(array $mapping) public function mapOneToOne(array $mapping)
{ {
$mapping['type'] = self::ONE_TO_ONE; $mapping['type'] = self::ONE_TO_ONE;
$mapping = $this->_validateAndCompleteOneToOneMapping($mapping); $mapping = $this->_validateAndCompleteOneToOneMapping($mapping);
$this->_storeAssociationMapping($mapping); $this->_storeAssociationMapping($mapping);
} }
@ -2530,7 +2567,9 @@ class ClassMetadataInfo implements ClassMetadata
public function mapOneToMany(array $mapping) public function mapOneToMany(array $mapping)
{ {
$mapping['type'] = self::ONE_TO_MANY; $mapping['type'] = self::ONE_TO_MANY;
$mapping = $this->_validateAndCompleteOneToManyMapping($mapping); $mapping = $this->_validateAndCompleteOneToManyMapping($mapping);
$this->_storeAssociationMapping($mapping); $this->_storeAssociationMapping($mapping);
} }
@ -2544,8 +2583,10 @@ class ClassMetadataInfo implements ClassMetadata
public function mapManyToOne(array $mapping) public function mapManyToOne(array $mapping)
{ {
$mapping['type'] = self::MANY_TO_ONE; $mapping['type'] = self::MANY_TO_ONE;
// A many-to-one mapping is essentially a one-one backreference // A many-to-one mapping is essentially a one-one backreference
$mapping = $this->_validateAndCompleteOneToOneMapping($mapping); $mapping = $this->_validateAndCompleteOneToOneMapping($mapping);
$this->_storeAssociationMapping($mapping); $this->_storeAssociationMapping($mapping);
} }
@ -2559,7 +2600,9 @@ class ClassMetadataInfo implements ClassMetadata
public function mapManyToMany(array $mapping) public function mapManyToMany(array $mapping)
{ {
$mapping['type'] = self::MANY_TO_MANY; $mapping['type'] = self::MANY_TO_MANY;
$mapping = $this->_validateAndCompleteManyToManyMapping($mapping); $mapping = $this->_validateAndCompleteManyToManyMapping($mapping);
$this->_storeAssociationMapping($mapping); $this->_storeAssociationMapping($mapping);
} }
@ -2677,9 +2720,10 @@ class ClassMetadataInfo implements ClassMetadata
public function addEntityListener($eventName, $class, $method) public function addEntityListener($eventName, $class, $method)
{ {
$class = $this->fullyQualifiedClassName($class); $class = $this->fullyQualifiedClassName($class);
$listener = array( $listener = array(
'class' => $class, 'class' => $class,
'method' => $method 'method' => $method,
); );
if ( ! class_exists($class)) { if ( ! class_exists($class)) {
@ -2764,6 +2808,7 @@ class ClassMetadataInfo implements ClassMetadata
{ {
$className = $this->fullyQualifiedClassName($className); $className = $this->fullyQualifiedClassName($className);
$className = ltrim($className, '\\'); $className = ltrim($className, '\\');
$this->discriminatorMap[$name] = $className; $this->discriminatorMap[$name] = $className;
if ($this->name === $className) { if ($this->name === $className) {
@ -2830,8 +2875,8 @@ class ClassMetadataInfo implements ClassMetadata
*/ */
public function isSingleValuedAssociation($fieldName) public function isSingleValuedAssociation($fieldName)
{ {
return isset($this->associationMappings[$fieldName]) && return isset($this->associationMappings[$fieldName])
($this->associationMappings[$fieldName]['type'] & self::TO_ONE); && ($this->associationMappings[$fieldName]['type'] & self::TO_ONE);
} }
/** /**
@ -2839,8 +2884,8 @@ class ClassMetadataInfo implements ClassMetadata
*/ */
public function isCollectionValuedAssociation($fieldName) public function isCollectionValuedAssociation($fieldName)
{ {
return isset($this->associationMappings[$fieldName]) && return isset($this->associationMappings[$fieldName])
! ($this->associationMappings[$fieldName]['type'] & self::TO_ONE); && ! ($this->associationMappings[$fieldName]['type'] & self::TO_ONE);
} }
/** /**
@ -2852,11 +2897,9 @@ class ClassMetadataInfo implements ClassMetadata
*/ */
public function isAssociationWithSingleJoinColumn($fieldName) public function isAssociationWithSingleJoinColumn($fieldName)
{ {
return ( return isset($this->associationMappings[$fieldName])
isset($this->associationMappings[$fieldName]) && && isset($this->associationMappings[$fieldName]['joinColumns'][0])
isset($this->associationMappings[$fieldName]['joinColumns'][0]) && && ! isset($this->associationMappings[$fieldName]['joinColumns'][1]);
!isset($this->associationMappings[$fieldName]['joinColumns'][1])
);
} }
/** /**
@ -2873,6 +2916,7 @@ class ClassMetadataInfo implements ClassMetadata
if ( ! $this->isAssociationWithSingleJoinColumn($fieldName)) { if ( ! $this->isAssociationWithSingleJoinColumn($fieldName)) {
throw MappingException::noSingleAssociationJoinColumnFound($this->name, $fieldName); throw MappingException::noSingleAssociationJoinColumnFound($this->name, $fieldName);
} }
return $this->associationMappings[$fieldName]['joinColumns'][0]['name']; return $this->associationMappings[$fieldName]['joinColumns'][0]['name'];
} }
@ -2890,6 +2934,7 @@ class ClassMetadataInfo implements ClassMetadata
if ( ! $this->isAssociationWithSingleJoinColumn($fieldName)) { if ( ! $this->isAssociationWithSingleJoinColumn($fieldName)) {
throw MappingException::noSingleAssociationJoinColumnFound($this->name, $fieldName); throw MappingException::noSingleAssociationJoinColumnFound($this->name, $fieldName);
} }
return $this->associationMappings[$fieldName]['joinColumns'][0]['referencedColumnName']; return $this->associationMappings[$fieldName]['joinColumns'][0]['referencedColumnName'];
} }
@ -2961,6 +3006,8 @@ class ClassMetadataInfo implements ClassMetadata
* @param array $definition * @param array $definition
* *
* @return void * @return void
*
* @throws MappingException
*/ */
public function setSequenceGeneratorDefinition(array $definition) public function setSequenceGeneratorDefinition(array $definition)
{ {
@ -3142,7 +3189,9 @@ class ClassMetadataInfo implements ClassMetadata
*/ */
public function getQuotedTableName($platform) public function getQuotedTableName($platform)
{ {
return isset($this->table['quoted']) ? $platform->quoteIdentifier($this->table['name']) : $this->table['name']; return isset($this->table['quoted'])
? $platform->quoteIdentifier($this->table['name'])
: $this->table['name'];
} }
/** /**
@ -3157,7 +3206,9 @@ class ClassMetadataInfo implements ClassMetadata
*/ */
public function getQuotedJoinTableName(array $assoc, $platform) public function getQuotedJoinTableName(array $assoc, $platform)
{ {
return isset($assoc['joinTable']['quoted']) ? $platform->quoteIdentifier($assoc['joinTable']['name']) : $assoc['joinTable']['name']; return isset($assoc['joinTable']['quoted'])
? $platform->quoteIdentifier($assoc['joinTable']['name'])
: $assoc['joinTable']['name'];
} }
/** /**
@ -3165,7 +3216,8 @@ class ClassMetadataInfo implements ClassMetadata
*/ */
public function isAssociationInverseSide($fieldName) public function isAssociationInverseSide($fieldName)
{ {
return isset($this->associationMappings[$fieldName]) && ! $this->associationMappings[$fieldName]['isOwningSide']; return isset($this->associationMappings[$fieldName])
&& ! $this->associationMappings[$fieldName]['isOwningSide'];
} }
/** /**
@ -3184,11 +3236,13 @@ class ClassMetadataInfo implements ClassMetadata
public function getAssociationsByTargetClass($targetClass) public function getAssociationsByTargetClass($targetClass)
{ {
$relations = array(); $relations = array();
foreach ($this->associationMappings as $mapping) { foreach ($this->associationMappings as $mapping) {
if ($mapping['targetEntity'] == $targetClass) { if ($mapping['targetEntity'] == $targetClass) {
$relations[$mapping['fieldName']] = $mapping; $relations[$mapping['fieldName']] = $mapping;
} }
} }
return $relations; return $relations;
} }
@ -3303,7 +3357,6 @@ class ClassMetadataInfo implements ClassMetadata
public function getSequenceName(AbstractPlatform $platform) public function getSequenceName(AbstractPlatform $platform)
{ {
$sequencePrefix = $this->getSequencePrefix($platform); $sequencePrefix = $this->getSequencePrefix($platform);
$columnName = $this->getSingleIdentifierColumnName(); $columnName = $this->getSingleIdentifierColumnName();
$sequenceName = $sequencePrefix . '_' . $columnName . '_seq'; $sequenceName = $sequencePrefix . '_' . $columnName . '_seq';

View File

@ -54,6 +54,7 @@ class AnnotationDriver extends AbstractAnnotationDriver
{ {
/* @var $metadata \Doctrine\ORM\Mapping\ClassMetadataInfo */ /* @var $metadata \Doctrine\ORM\Mapping\ClassMetadataInfo */
$class = $metadata->getReflectionClass(); $class = $metadata->getReflectionClass();
if ( ! $class) { if ( ! $class) {
// this happens when running annotation driver in combination with // this happens when running annotation driver in combination with
// static reflection services. This is not the nicest fix // static reflection services. This is not the nicest fix
@ -78,11 +79,13 @@ class AnnotationDriver extends AbstractAnnotationDriver
if ($entityAnnot->repositoryClass !== null) { if ($entityAnnot->repositoryClass !== null) {
$metadata->setCustomRepositoryClass($entityAnnot->repositoryClass); $metadata->setCustomRepositoryClass($entityAnnot->repositoryClass);
} }
if ($entityAnnot->readOnly) { if ($entityAnnot->readOnly) {
$metadata->markReadOnly(); $metadata->markReadOnly();
} }
} else if (isset($classAnnotations['Doctrine\ORM\Mapping\MappedSuperclass'])) { } else if (isset($classAnnotations['Doctrine\ORM\Mapping\MappedSuperclass'])) {
$mappedSuperclassAnnot = $classAnnotations['Doctrine\ORM\Mapping\MappedSuperclass']; $mappedSuperclassAnnot = $classAnnotations['Doctrine\ORM\Mapping\MappedSuperclass'];
$metadata->setCustomRepositoryClass($mappedSuperclassAnnot->repositoryClass); $metadata->setCustomRepositoryClass($mappedSuperclassAnnot->repositoryClass);
$metadata->isMappedSuperclass = true; $metadata->isMappedSuperclass = true;
} else if (isset($classAnnotations['Doctrine\ORM\Mapping\Embeddable'])) { } else if (isset($classAnnotations['Doctrine\ORM\Mapping\Embeddable'])) {
@ -227,17 +230,21 @@ class AnnotationDriver extends AbstractAnnotationDriver
// Evaluate InheritanceType annotation // Evaluate InheritanceType annotation
if (isset($classAnnotations['Doctrine\ORM\Mapping\InheritanceType'])) { if (isset($classAnnotations['Doctrine\ORM\Mapping\InheritanceType'])) {
$inheritanceTypeAnnot = $classAnnotations['Doctrine\ORM\Mapping\InheritanceType']; $inheritanceTypeAnnot = $classAnnotations['Doctrine\ORM\Mapping\InheritanceType'];
$metadata->setInheritanceType(constant('Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . $inheritanceTypeAnnot->value));
$metadata->setInheritanceType(
constant('Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . $inheritanceTypeAnnot->value)
);
if ($metadata->inheritanceType != \Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_NONE) { if ($metadata->inheritanceType != \Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_NONE) {
// Evaluate DiscriminatorColumn annotation // Evaluate DiscriminatorColumn annotation
if (isset($classAnnotations['Doctrine\ORM\Mapping\DiscriminatorColumn'])) { if (isset($classAnnotations['Doctrine\ORM\Mapping\DiscriminatorColumn'])) {
$discrColumnAnnot = $classAnnotations['Doctrine\ORM\Mapping\DiscriminatorColumn']; $discrColumnAnnot = $classAnnotations['Doctrine\ORM\Mapping\DiscriminatorColumn'];
$metadata->setDiscriminatorColumn(array( $metadata->setDiscriminatorColumn(array(
'name' => $discrColumnAnnot->name, 'name' => $discrColumnAnnot->name,
'type' => $discrColumnAnnot->type, 'type' => $discrColumnAnnot->type,
'length' => $discrColumnAnnot->length, 'length' => $discrColumnAnnot->length,
'columnDefinition' => $discrColumnAnnot->columnDefinition 'columnDefinition' => $discrColumnAnnot->columnDefinition,
)); ));
} else { } else {
$metadata->setDiscriminatorColumn(array('name' => 'dtype', 'type' => 'string', 'length' => 255)); $metadata->setDiscriminatorColumn(array('name' => 'dtype', 'type' => 'string', 'length' => 255));
@ -273,6 +280,7 @@ class AnnotationDriver extends AbstractAnnotationDriver
$mapping = array(); $mapping = array();
$mapping['fieldName'] = $property->getName(); $mapping['fieldName'] = $property->getName();
// Evaluate @Cache annotation // Evaluate @Cache annotation
if (($cacheAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\Cache')) !== null) { if (($cacheAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\Cache')) !== null) {
$mapping['cache'] = $metadata->getAssociationCacheDefaults($mapping['fieldName'], array( $mapping['cache'] = $metadata->getAssociationCacheDefaults($mapping['fieldName'], array(
@ -400,6 +408,7 @@ class AnnotationDriver extends AbstractAnnotationDriver
} else if ($embeddedAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\Embedded')) { } else if ($embeddedAnnot = $this->reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\Embedded')) {
$mapping['class'] = $embeddedAnnot->class; $mapping['class'] = $embeddedAnnot->class;
$mapping['columnPrefix'] = $embeddedAnnot->columnPrefix; $mapping['columnPrefix'] = $embeddedAnnot->columnPrefix;
$metadata->mapEmbedded($mapping); $metadata->mapEmbedded($mapping);
} }
} }
@ -415,9 +424,11 @@ class AnnotationDriver extends AbstractAnnotationDriver
// Check for JoinColumn/JoinColumns annotations // Check for JoinColumn/JoinColumns annotations
if ($associationOverride->joinColumns) { if ($associationOverride->joinColumns) {
$joinColumns = array(); $joinColumns = array();
foreach ($associationOverride->joinColumns as $joinColumn) { foreach ($associationOverride->joinColumns as $joinColumn) {
$joinColumns[] = $this->joinColumnToArray($joinColumn); $joinColumns[] = $this->joinColumnToArray($joinColumn);
} }
$override['joinColumns'] = $joinColumns; $override['joinColumns'] = $joinColumns;
} }
@ -452,8 +463,10 @@ class AnnotationDriver extends AbstractAnnotationDriver
// Evaluate AttributeOverrides annotation // Evaluate AttributeOverrides annotation
if (isset($classAnnotations['Doctrine\ORM\Mapping\AttributeOverrides'])) { if (isset($classAnnotations['Doctrine\ORM\Mapping\AttributeOverrides'])) {
$attributeOverridesAnnot = $classAnnotations['Doctrine\ORM\Mapping\AttributeOverrides']; $attributeOverridesAnnot = $classAnnotations['Doctrine\ORM\Mapping\AttributeOverrides'];
foreach ($attributeOverridesAnnot->value as $attributeOverrideAnnot) { foreach ($attributeOverridesAnnot->value as $attributeOverrideAnnot) {
$attributeOverride = $this->columnToArray($attributeOverrideAnnot->name, $attributeOverrideAnnot->column); $attributeOverride = $this->columnToArray($attributeOverrideAnnot->name, $attributeOverrideAnnot->column);
$metadata->setAttributeOverride($attributeOverrideAnnot->name, $attributeOverride); $metadata->setAttributeOverride($attributeOverrideAnnot->name, $attributeOverride);
} }
} }
@ -471,6 +484,7 @@ class AnnotationDriver extends AbstractAnnotationDriver
$hasMapping = false; $hasMapping = false;
$listenerClass = new \ReflectionClass($listenerClassName); $listenerClass = new \ReflectionClass($listenerClassName);
/* @var $method \ReflectionMethod */ /* @var $method \ReflectionMethod */
foreach ($listenerClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { foreach ($listenerClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
// find method callbacks. // find method callbacks.
@ -481,6 +495,7 @@ class AnnotationDriver extends AbstractAnnotationDriver
$metadata->addEntityListener($value[1], $listenerClassName, $value[0]); $metadata->addEntityListener($value[1], $listenerClassName, $value[0]);
} }
} }
// Evaluate the listener using naming convention. // Evaluate the listener using naming convention.
if ( ! $hasMapping ) { if ( ! $hasMapping ) {
EntityListenerBuilder::bindEntityListener($metadata, $listenerClassName); EntityListenerBuilder::bindEntityListener($metadata, $listenerClassName);
@ -492,9 +507,7 @@ class AnnotationDriver extends AbstractAnnotationDriver
if (isset($classAnnotations['Doctrine\ORM\Mapping\HasLifecycleCallbacks'])) { if (isset($classAnnotations['Doctrine\ORM\Mapping\HasLifecycleCallbacks'])) {
/* @var $method \ReflectionMethod */ /* @var $method \ReflectionMethod */
foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
foreach ($this->getMethodCallbacks($method) as $value) { foreach ($this->getMethodCallbacks($method) as $value) {
$metadata->addLifecycleCallback($value[0], $value[1]); $metadata->addLifecycleCallback($value[0], $value[1]);
} }
} }

View File

@ -715,6 +715,7 @@ class YamlDriver extends FileDriver
if (isset($column['type'])) { if (isset($column['type'])) {
$params = explode('(', $column['type']); $params = explode('(', $column['type']);
$column['type'] = $params[0]; $column['type'] = $params[0];
$mapping['type'] = $column['type']; $mapping['type'] = $column['type'];

View File

@ -471,7 +471,7 @@ final class PersistentCollection extends AbstractLazyCollection implements Selec
$this->changed(); $this->changed();
if ($this->em) { if (is_object($value) && $this->em) {
$this->em->getUnitOfWork()->cancelOrphanRemoval($value); $this->em->getUnitOfWork()->cancelOrphanRemoval($value);
} }
} }
@ -485,7 +485,7 @@ final class PersistentCollection extends AbstractLazyCollection implements Selec
$this->changed(); $this->changed();
if ($this->em) { if (is_object($value) && $this->em) {
$this->em->getUnitOfWork()->cancelOrphanRemoval($value); $this->em->getUnitOfWork()->cancelOrphanRemoval($value);
} }

View File

@ -23,6 +23,7 @@ use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Proxy\Proxy; use Doctrine\Common\Proxy\Proxy;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\PersistentCollection;
use Doctrine\ORM\Utility\PersisterHelper;
/** /**
* Persister for one-to-many collections. * Persister for one-to-many collections.
@ -251,7 +252,7 @@ class OneToManyPersister extends AbstractCollectionPersister
foreach ($idColumnNames as $idColumnName) { foreach ($idColumnNames as $idColumnName) {
$columnDefinitions[$idColumnName] = array( $columnDefinitions[$idColumnName] = array(
'notnull' => true, 'notnull' => true,
'type' => Type::getType($rootClass->getTypeOfColumn($idColumnName)), 'type' => Type::getType(PersisterHelper::getTypeOfColumn($idColumnName, $rootClass, $this->em)),
); );
} }

View File

@ -61,15 +61,18 @@ abstract class AbstractEntityInheritancePersister extends BasicEntityPersister
protected function getSelectColumnSQL($field, ClassMetadata $class, $alias = 'r') protected function getSelectColumnSQL($field, ClassMetadata $class, $alias = 'r')
{ {
$tableAlias = $alias == 'r' ? '' : $alias; $tableAlias = $alias == 'r' ? '' : $alias;
$columnName = $class->columnNames[$field]; $fieldMapping = $class->fieldMappings[$field];
$columnAlias = $this->getSQLColumnAlias($columnName); $columnAlias = $this->getSQLColumnAlias($fieldMapping['columnName']);
$sql = $this->getSQLTableAlias($class->name, $tableAlias) . '.' $sql = sprintf(
. $this->quoteStrategy->getColumnName($field, $class, $this->platform); '%s.%s',
$this->getSQLTableAlias($class->name, $tableAlias),
$this->quoteStrategy->getColumnName($field, $class, $this->platform)
);
$this->currentPersisterContext->rsm->addFieldResult($alias, $columnAlias, $field, $class->name); $this->currentPersisterContext->rsm->addFieldResult($alias, $columnAlias, $field, $class->name);
if (isset($class->fieldMappings[$field]['requireSQLConversion'])) { if (isset($fieldMapping['requireSQLConversion'])) {
$type = Type::getType($class->getTypeOfField($field)); $type = Type::getType($fieldMapping['type']);
$sql = $type->convertToPHPValueSQL($sql, $this->platform); $sql = $type->convertToPHPValueSQL($sql, $this->platform);
} }

View File

@ -332,6 +332,7 @@ class BasicEntityPersister implements EntityPersister
protected function fetchVersionValue($versionedClass, array $id) protected function fetchVersionValue($versionedClass, array $id)
{ {
$versionField = $versionedClass->versionField; $versionField = $versionedClass->versionField;
$fieldMapping = $versionedClass->fieldMappings[$versionField];
$tableName = $this->quoteStrategy->getTableName($versionedClass, $this->platform); $tableName = $this->quoteStrategy->getTableName($versionedClass, $this->platform);
$identifier = $this->quoteStrategy->getIdentifierColumnNames($versionedClass, $this->platform); $identifier = $this->quoteStrategy->getIdentifierColumnNames($versionedClass, $this->platform);
$columnName = $this->quoteStrategy->getColumnName($versionField, $versionedClass, $this->platform); $columnName = $this->quoteStrategy->getColumnName($versionField, $versionedClass, $this->platform);
@ -345,7 +346,7 @@ class BasicEntityPersister implements EntityPersister
$value = $this->conn->fetchColumn($sql, array_values($flatId)); $value = $this->conn->fetchColumn($sql, array_values($flatId));
return Type::getType($versionedClass->fieldMappings[$versionField]['type'])->convertToPHPValue($value, $this->platform); return Type::getType($fieldMapping['type'])->convertToPHPValue($value, $this->platform);
} }
/** /**
@ -424,7 +425,6 @@ class BasicEntityPersister implements EntityPersister
foreach ($this->class->identifier as $idField) { foreach ($this->class->identifier as $idField) {
if ( ! isset($this->class->associationMappings[$idField])) { if ( ! isset($this->class->associationMappings[$idField])) {
$params[] = $identifier[$idField]; $params[] = $identifier[$idField];
$types[] = $this->class->fieldMappings[$idField]['type']; $types[] = $this->class->fieldMappings[$idField]['type'];
$where[] = $this->quoteStrategy->getColumnName($idField, $this->class, $this->platform); $where[] = $this->quoteStrategy->getColumnName($idField, $this->class, $this->platform);
@ -550,18 +550,18 @@ class BasicEntityPersister implements EntityPersister
*/ */
public function delete($entity) public function delete($entity)
{ {
$self = $this;
$class = $this->class; $class = $this->class;
$identifier = $this->em->getUnitOfWork()->getEntityIdentifier($entity); $identifier = $this->em->getUnitOfWork()->getEntityIdentifier($entity);
$tableName = $this->quoteStrategy->getTableName($class, $this->platform); $tableName = $this->quoteStrategy->getTableName($class, $this->platform);
$idColumns = $this->quoteStrategy->getIdentifierColumnNames($class, $this->platform); $idColumns = $this->quoteStrategy->getIdentifierColumnNames($class, $this->platform);
$id = array_combine($idColumns, $identifier); $id = array_combine($idColumns, $identifier);
$types = array_map(function ($identifier) use ($class) { $types = array_map(function ($identifier) use ($class, $self) {
if (isset($class->fieldMappings[$identifier])) { if (isset($class->fieldMappings[$identifier])) {
return $class->fieldMappings[$identifier]['type']; return $class->fieldMappings[$identifier]['type'];
} }
$targetMapping = $this->em->getClassMetadata($class->associationMappings[$identifier]['targetEntity']); $targetMapping = $self->em->getClassMetadata($class->associationMappings[$identifier]['targetEntity']);
if (isset($targetMapping->fieldMappings[$targetMapping->identifier[0]])) { if (isset($targetMapping->fieldMappings[$targetMapping->identifier[0]])) {
return $targetMapping->fieldMappings[$targetMapping->identifier[0]]['type']; return $targetMapping->fieldMappings[$targetMapping->identifier[0]]['type'];
@ -572,7 +572,6 @@ class BasicEntityPersister implements EntityPersister
} }
throw ORMException::unrecognizedField($targetMapping->identifier[0]); throw ORMException::unrecognizedField($targetMapping->identifier[0]);
}, $class->identifier); }, $class->identifier);
$this->deleteJoinTableRecords($identifier); $this->deleteJoinTableRecords($identifier);
@ -623,8 +622,11 @@ class BasicEntityPersister implements EntityPersister
$newVal = $change[1]; $newVal = $change[1];
if ( ! isset($this->class->associationMappings[$field])) { if ( ! isset($this->class->associationMappings[$field])) {
$columnName = $this->class->columnNames[$field]; $fieldMapping = $this->class->fieldMappings[$field];
$this->columnTypes[$columnName] = $this->class->fieldMappings[$field]['type']; $columnName = $fieldMapping['columnName'];
$this->columnTypes[$columnName] = $fieldMapping['type'];
$result[$this->getOwningTable($field)][$columnName] = $newVal; $result[$this->getOwningTable($field)][$columnName] = $newVal;
continue; continue;
@ -988,7 +990,6 @@ class BasicEntityPersister implements EntityPersister
$quotedJoinTable = $this->quoteStrategy->getJoinTableName($association, $class, $this->platform); $quotedJoinTable = $this->quoteStrategy->getJoinTableName($association, $class, $this->platform);
foreach ($joinColumns as $joinColumn) { foreach ($joinColumns as $joinColumn) {
$sourceKeyColumn = $joinColumn['referencedColumnName']; $sourceKeyColumn = $joinColumn['referencedColumnName'];
$quotedKeyColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform); $quotedKeyColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform);
@ -1316,17 +1317,17 @@ class BasicEntityPersister implements EntityPersister
$columnList = array(); $columnList = array();
$targetClass = $this->em->getClassMetadata($assoc['targetEntity']); $targetClass = $this->em->getClassMetadata($assoc['targetEntity']);
$isIdentifier = isset($assoc['id']) && $assoc['id'] === true;
$sqlTableAlias = $this->getSQLTableAlias($class->name, ($alias == 'r' ? '' : $alias));
foreach ($assoc['joinColumns'] as $joinColumn) { foreach ($assoc['joinColumns'] as $joinColumn) {
$type = null;
$isIdentifier = isset($assoc['id']) && $assoc['id'] === true;
$quotedColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform); $quotedColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform);
$resultColumnName = $this->getSQLColumnAlias($joinColumn['name']); $resultColumnName = $this->getSQLColumnAlias($joinColumn['name']);
$columnList[] = $this->getSQLTableAlias($class->name, ($alias == 'r' ? '' : $alias) )
. '.' . $quotedColumn . ' AS ' . $resultColumnName;
$type = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em); $type = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em);
$this->currentPersisterContext->rsm->addMetaResult($alias, $resultColumnName, $quotedColumn, $isIdentifier, $type); $this->currentPersisterContext->rsm->addMetaResult($alias, $resultColumnName, $quotedColumn, $isIdentifier, $type);
$columnList[] = sprintf('%s.%s AS %s', $sqlTableAlias, $quotedColumn, $resultColumnName);
} }
return implode(', ', $columnList); return implode(', ', $columnList);
@ -1393,7 +1394,6 @@ class BasicEntityPersister implements EntityPersister
if (isset($this->class->fieldNames[$column]) if (isset($this->class->fieldNames[$column])
&& isset($this->columnTypes[$this->class->fieldNames[$column]]) && isset($this->columnTypes[$this->class->fieldNames[$column]])
&& isset($this->class->fieldMappings[$this->class->fieldNames[$column]]['requireSQLConversion'])) { && isset($this->class->fieldMappings[$this->class->fieldNames[$column]]['requireSQLConversion'])) {
$type = Type::getType($this->columnTypes[$this->class->fieldNames[$column]]); $type = Type::getType($this->columnTypes[$this->class->fieldNames[$column]]);
$placeholder = $type->convertToDatabaseValueSQL('?', $this->platform); $placeholder = $type->convertToDatabaseValueSQL('?', $this->platform);
} }
@ -1432,6 +1432,7 @@ class BasicEntityPersister implements EntityPersister
if (isset($this->class->associationMappings[$name])) { if (isset($this->class->associationMappings[$name])) {
$assoc = $this->class->associationMappings[$name]; $assoc = $this->class->associationMappings[$name];
if ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE) { if ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE) {
foreach ($assoc['joinColumns'] as $joinColumn) { foreach ($assoc['joinColumns'] as $joinColumn) {
$columns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform); $columns[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform);
@ -1464,14 +1465,14 @@ class BasicEntityPersister implements EntityPersister
{ {
$root = $alias == 'r' ? '' : $alias ; $root = $alias == 'r' ? '' : $alias ;
$tableAlias = $this->getSQLTableAlias($class->name, $root); $tableAlias = $this->getSQLTableAlias($class->name, $root);
$columnName = $this->quoteStrategy->getColumnName($field, $class, $this->platform); $fieldMapping = $class->fieldMappings[$field];
$sql = $tableAlias . '.' . $columnName; $sql = sprintf('%s.%s', $tableAlias, $this->quoteStrategy->getColumnName($field, $class, $this->platform));
$columnAlias = $this->getSQLColumnAlias($class->columnNames[$field]); $columnAlias = $this->getSQLColumnAlias($fieldMapping['columnName']);
$this->currentPersisterContext->rsm->addFieldResult($alias, $columnAlias, $field); $this->currentPersisterContext->rsm->addFieldResult($alias, $columnAlias, $field);
if (isset($class->fieldMappings[$field]['requireSQLConversion'])) { if (isset($fieldMapping['requireSQLConversion'])) {
$type = Type::getType($class->getTypeOfField($field)); $type = Type::getType($fieldMapping['type']);
$sql = $type->convertToPHPValueSQL($sql, $this->platform); $sql = $type->convertToPHPValueSQL($sql, $this->platform);
} }
@ -1593,22 +1594,26 @@ class BasicEntityPersister implements EntityPersister
$placeholder = '?'; $placeholder = '?';
if (isset($this->class->fieldMappings[$field]['requireSQLConversion'])) { if (isset($this->class->fieldMappings[$field]['requireSQLConversion'])) {
$placeholder = Type::getType($this->class->getTypeOfField($field))->convertToDatabaseValueSQL($placeholder, $this->platform); $type = Type::getType($this->class->fieldMappings[$field]['type']);
$placeholder = $type->convertToDatabaseValueSQL($placeholder, $this->platform);
} }
if (null !== $comparison) { if (null !== $comparison) {
// special case null value handling // special case null value handling
if (($comparison === Comparison::EQ || $comparison === Comparison::IS) && null ===$value) { if (($comparison === Comparison::EQ || $comparison === Comparison::IS) && null ===$value) {
$selectedColumns[] = $column . ' IS NULL'; $selectedColumns[] = $column . ' IS NULL';
continue; continue;
} }
if ($comparison === Comparison::NEQ && null === $value) { if ($comparison === Comparison::NEQ && null === $value) {
$selectedColumns[] = $column . ' IS NOT NULL'; $selectedColumns[] = $column . ' IS NOT NULL';
continue; continue;
} }
$selectedColumns[] = $column . ' ' . sprintf(self::$comparisonMap[$comparison], $placeholder); $selectedColumns[] = $column . ' ' . sprintf(self::$comparisonMap[$comparison], $placeholder);
continue; continue;
} }
@ -1617,15 +1622,18 @@ class BasicEntityPersister implements EntityPersister
if (false !== array_search(null, $value, true)) { if (false !== array_search(null, $value, true)) {
$selectedColumns[] = sprintf('(%s OR %s IS NULL)', $in, $column); $selectedColumns[] = sprintf('(%s OR %s IS NULL)', $in, $column);
continue; continue;
} }
$selectedColumns[] = $in; $selectedColumns[] = $in;
continue; continue;
} }
if (null === $value) { if (null === $value) {
$selectedColumns[] = sprintf('%s IS NULL', $column); $selectedColumns[] = sprintf('%s IS NULL', $column);
continue; continue;
} }
@ -1647,7 +1655,7 @@ class BasicEntityPersister implements EntityPersister
*/ */
private function getSelectConditionStatementColumnSQL($field, $assoc = null) private function getSelectConditionStatementColumnSQL($field, $assoc = null)
{ {
if (isset($this->class->columnNames[$field])) { if (isset($this->class->fieldMappings[$field])) {
$className = (isset($this->class->fieldMappings[$field]['inherited'])) $className = (isset($this->class->fieldMappings[$field]['inherited']))
? $this->class->fieldMappings[$field]['inherited'] ? $this->class->fieldMappings[$field]['inherited']
: $this->class->name; : $this->class->name;
@ -1677,7 +1685,6 @@ class BasicEntityPersister implements EntityPersister
} }
} else { } else {
if ( ! $association['isOwningSide']) { if ( ! $association['isOwningSide']) {
throw ORMException::invalidFindByInverseAssociation($this->class->name, $field); throw ORMException::invalidFindByInverseAssociation($this->class->name, $field);
} }
@ -1767,7 +1774,6 @@ class BasicEntityPersister implements EntityPersister
$parameters = array(); $parameters = array();
$owningAssoc = $this->class->associationMappings[$assoc['mappedBy']]; $owningAssoc = $this->class->associationMappings[$assoc['mappedBy']];
$sourceClass = $this->em->getClassMetadata($assoc['sourceEntity']); $sourceClass = $this->em->getClassMetadata($assoc['sourceEntity']);
$tableAlias = $this->getSQLTableAlias(isset($owningAssoc['inherited']) ? $owningAssoc['inherited'] : $this->class->name); $tableAlias = $this->getSQLTableAlias(isset($owningAssoc['inherited']) ? $owningAssoc['inherited'] : $this->class->name);
foreach ($owningAssoc['targetToSourceKeyColumns'] as $sourceKeyColumn => $targetKeyColumn) { foreach ($owningAssoc['targetToSourceKeyColumns'] as $sourceKeyColumn => $targetKeyColumn) {
@ -1873,7 +1879,7 @@ class BasicEntityPersister implements EntityPersister
switch (true) { switch (true) {
case (isset($class->fieldMappings[$field])): case (isset($class->fieldMappings[$field])):
$types = array_merge($types, PersisterHelper::getTypeOfField($field, $class, $this->em)); $types = array_merge($types, array($class->fieldMappings[$field]['type']));
break; break;
case (isset($class->associationMappings[$field])): case (isset($class->associationMappings[$field])):
@ -1900,12 +1906,11 @@ class BasicEntityPersister implements EntityPersister
} }
if (is_array($value)) { if (is_array($value)) {
return array_map( return array_map(function ($type) {
function ($type) { $type = Type::getType($type);
return Type::getType($type)->getBindingType() + Connection::ARRAY_PARAM_OFFSET;
}, return $type->getBindingType() + Connection::ARRAY_PARAM_OFFSET;
$types }, $types);
);
} }
return $types; return $types;

View File

@ -258,10 +258,12 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
if ($isVersioned) { if ($isVersioned) {
if ( ! isset($updateData[$versionedTable])) { if ( ! isset($updateData[$versionedTable])) {
$tableName = $this->quoteStrategy->getTableName($versionedClass, $this->platform); $tableName = $this->quoteStrategy->getTableName($versionedClass, $this->platform);
$this->updateTable($entity, $tableName, array(), true); $this->updateTable($entity, $tableName, array(), true);
} }
$identifiers = $this->em->getUnitOfWork()->getEntityIdentifier($entity); $identifiers = $this->em->getUnitOfWork()->getEntityIdentifier($entity);
$this->assignDefaultVersionValue($entity, $identifiers); $this->assignDefaultVersionValue($entity, $identifiers);
} }
} }
@ -434,12 +436,13 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
$columnList = array(); $columnList = array();
$discrColumn = $this->class->discriminatorColumn['name']; $discrColumn = $this->class->discriminatorColumn['name'];
$discrColumnType = $this->class->discriminatorColumn['type'];
$baseTableAlias = $this->getSQLTableAlias($this->class->name); $baseTableAlias = $this->getSQLTableAlias($this->class->name);
$resultColumnName = $this->platform->getSQLResultCasing($discrColumn); $resultColumnName = $this->platform->getSQLResultCasing($discrColumn);
$this->currentPersisterContext->rsm->addEntityResult($this->class->name, 'r'); $this->currentPersisterContext->rsm->addEntityResult($this->class->name, 'r');
$this->currentPersisterContext->rsm->setDiscriminatorColumn('r', $resultColumnName); $this->currentPersisterContext->rsm->setDiscriminatorColumn('r', $resultColumnName);
$this->currentPersisterContext->rsm->addMetaResult('r', $resultColumnName, $discrColumn); $this->currentPersisterContext->rsm->addMetaResult('r', $resultColumnName, $discrColumn, false, $discrColumnType);
// Add regular columns // Add regular columns
foreach ($this->class->fieldMappings as $fieldName => $mapping) { foreach ($this->class->fieldMappings as $fieldName => $mapping) {

View File

@ -59,12 +59,14 @@ class SingleTablePersister extends AbstractEntityInheritancePersister
// Append discriminator column // Append discriminator column
$discrColumn = $this->class->discriminatorColumn['name']; $discrColumn = $this->class->discriminatorColumn['name'];
$discrColumnType = $this->class->discriminatorColumn['type'];
$columnList[] = $tableAlias . '.' . $discrColumn; $columnList[] = $tableAlias . '.' . $discrColumn;
$resultColumnName = $this->platform->getSQLResultCasing($discrColumn); $resultColumnName = $this->platform->getSQLResultCasing($discrColumn);
$this->currentPersisterContext->rsm->setDiscriminatorColumn('r', $resultColumnName); $this->currentPersisterContext->rsm->setDiscriminatorColumn('r', $resultColumnName);
$this->currentPersisterContext->rsm->addMetaResult('r', $resultColumnName, $discrColumn); $this->currentPersisterContext->rsm->addMetaResult('r', $resultColumnName, $discrColumn, false, $discrColumnType);
// Append subclass columns // Append subclass columns
foreach ($this->class->subClasses as $subClassName) { foreach ($this->class->subClasses as $subClassName) {
@ -81,17 +83,14 @@ class SingleTablePersister extends AbstractEntityInheritancePersister
// Foreign key columns // Foreign key columns
foreach ($subClass->associationMappings as $assoc) { foreach ($subClass->associationMappings as $assoc) {
if ( ! $assoc['isOwningSide'] if ( ! $assoc['isOwningSide'] || ! ($assoc['type'] & ClassMetadata::TO_ONE) || isset($assoc['inherited'])) {
|| ! ($assoc['type'] & ClassMetadata::TO_ONE)
|| isset($assoc['inherited'])) {
continue; continue;
} }
foreach ($assoc['targetToSourceKeyColumns'] as $srcColumn) {
$className = isset($assoc['inherited']) ? $assoc['inherited'] : $this->class->name; $className = isset($assoc['inherited']) ? $assoc['inherited'] : $this->class->name;
$targetClass = $this->em->getClassMetadata($assoc['targetEntity']); $targetClass = $this->em->getClassMetadata($assoc['targetEntity']);
foreach ($assoc['targetToSourceKeyColumns'] as $srcColumn) {
$columnList[] = $this->getSelectJoinColumnSQL( $columnList[] = $this->getSelectJoinColumnSQL(
$tableAlias, $tableAlias,
$srcColumn, $srcColumn,

View File

@ -20,7 +20,9 @@
namespace Doctrine\ORM\Query\Exec; namespace Doctrine\ORM\Query\Exec;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Types\Type;
use Doctrine\ORM\Query\AST; use Doctrine\ORM\Query\AST;
use Doctrine\ORM\Utility\PersisterHelper;
/** /**
* Executes the SQL statements for bulk DQL DELETE statements on classes in * Executes the SQL statements for bulk DQL DELETE statements on classes in
@ -103,7 +105,7 @@ class MultiTableDeleteExecutor extends AbstractSqlExecutor
foreach ($idColumnNames as $idColumnName) { foreach ($idColumnNames as $idColumnName) {
$columnDefinitions[$idColumnName] = array( $columnDefinitions[$idColumnName] = array(
'notnull' => true, 'notnull' => true,
'type' => \Doctrine\DBAL\Types\Type::getType($rootClass->getTypeOfColumn($idColumnName)) 'type' => Type::getType(PersisterHelper::getTypeOfColumn($idColumnName, $rootClass, $em)),
); );
} }
$this->_createTempTableSql = $platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable . ' (' $this->_createTempTableSql = $platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable . ' ('

View File

@ -21,9 +21,9 @@ namespace Doctrine\ORM\Query\Exec;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use Doctrine\ORM\Query\ParameterTypeInferer; use Doctrine\ORM\Query\ParameterTypeInferer;
use Doctrine\ORM\Query\AST; use Doctrine\ORM\Query\AST;
use Doctrine\ORM\Utility\PersisterHelper;
/** /**
* Executes the SQL statements for bulk DQL UPDATE statements on classes in * Executes the SQL statements for bulk DQL UPDATE statements on classes in
@ -111,8 +111,8 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
foreach ($updateItems as $updateItem) { foreach ($updateItems as $updateItem) {
$field = $updateItem->pathExpression->field; $field = $updateItem->pathExpression->field;
if (isset($class->fieldMappings[$field]) && ! isset($class->fieldMappings[$field]['inherited']) || if ((isset($class->fieldMappings[$field]) && ! isset($class->fieldMappings[$field]['inherited'])) ||
isset($class->associationMappings[$field]) && ! isset($class->associationMappings[$field]['inherited'])) { (isset($class->associationMappings[$field]) && ! isset($class->associationMappings[$field]['inherited']))) {
$newValue = $updateItem->newValue; $newValue = $updateItem->newValue;
if ( ! $affected) { if ( ! $affected) {
@ -148,7 +148,7 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
foreach ($idColumnNames as $idColumnName) { foreach ($idColumnNames as $idColumnName) {
$columnDefinitions[$idColumnName] = array( $columnDefinitions[$idColumnName] = array(
'notnull' => true, 'notnull' => true,
'type' => Type::getType($rootClass->getTypeOfColumn($idColumnName)) 'type' => Type::getType(PersisterHelper::getTypeOfColumn($idColumnName, $rootClass, $em)),
); );
} }

View File

@ -558,6 +558,8 @@ class ResultSetMapping
* @param string $type The column type * @param string $type The column type
* *
* @return ResultSetMapping This ResultSetMapping instance. * @return ResultSetMapping This ResultSetMapping instance.
*
* @todo Make all methods of this class require all parameters and not infer anything
*/ */
public function addMetaResult($alias, $columnName, $fieldName, $isIdentifierColumn = false, $type = null) public function addMetaResult($alias, $columnName, $fieldName, $isIdentifierColumn = false, $type = null)
{ {

View File

@ -19,8 +19,11 @@
namespace Doctrine\ORM\Query; namespace Doctrine\ORM\Query;
use Doctrine\DBAL\Types\Type;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\ORM\Mapping\ClassMetadataInfo;
use Doctrine\ORM\Mapping\MappingException;
use Doctrine\ORM\Utility\PersisterHelper;
/** /**
* A ResultSetMappingBuilder uses the EntityManager to automatically populate entity fields. * A ResultSetMappingBuilder uses the EntityManager to automatically populate entity fields.
@ -160,20 +163,19 @@ class ResultSetMappingBuilder extends ResultSetMapping
foreach ($classMetadata->associationMappings as $associationMapping) { foreach ($classMetadata->associationMappings as $associationMapping) {
if ($associationMapping['isOwningSide'] && $associationMapping['type'] & ClassMetadataInfo::TO_ONE) { if ($associationMapping['isOwningSide'] && $associationMapping['type'] & ClassMetadataInfo::TO_ONE) {
$targetClass = $this->em->getClassMetadata($associationMapping['targetEntity']);
$isIdentifier = isset($associationMapping['id']) && $associationMapping['id'] === true;
foreach ($associationMapping['joinColumns'] as $joinColumn) { foreach ($associationMapping['joinColumns'] as $joinColumn) {
$columnName = $joinColumn['name']; $columnName = $joinColumn['name'];
$columnAlias = $platform->getSQLResultCasing($columnAliasMap[$columnName]); $columnAlias = $platform->getSQLResultCasing($columnAliasMap[$columnName]);
$columnType = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em);
if (isset($this->metaMappings[$columnAlias])) { if (isset($this->metaMappings[$columnAlias])) {
throw new \InvalidArgumentException("The column '$columnAlias' conflicts with another column in the mapper."); throw new \InvalidArgumentException("The column '$columnAlias' conflicts with another column in the mapper.");
} }
$this->addMetaResult( $this->addMetaResult($alias, $columnAlias, $columnName, $isIdentifier, $columnType);
$alias,
$columnAlias,
$columnName,
(isset($associationMapping['id']) && $associationMapping['id'] === true)
);
} }
} }
} }
@ -284,21 +286,27 @@ class ResultSetMappingBuilder extends ResultSetMapping
$this->addEntityResult($class->name, $alias); $this->addEntityResult($class->name, $alias);
if ($classMetadata->discriminatorColumn) { if ($classMetadata->discriminatorColumn) {
$discriminatorColumn = $classMetadata->discriminatorColumn; $discrColumn = $classMetadata->discriminatorColumn;
$this->setDiscriminatorColumn($alias, $discriminatorColumn['name']);
$this->addMetaResult($alias, $discriminatorColumn['name'], $discriminatorColumn['fieldName']); $this->setDiscriminatorColumn($alias, $discrColumn['name']);
$this->addMetaResult($alias, $discrColumn['name'], $discrColumn['fieldName'], false, $discrColumn['type']);
} }
foreach ($classMetadata->getColumnNames() as $key => $columnName) { foreach ($classMetadata->getColumnNames() as $key => $columnName) {
$propertyName = $classMetadata->getFieldName($columnName); $propertyName = $classMetadata->getFieldName($columnName);
$this->addFieldResult($alias, $columnName, $propertyName); $this->addFieldResult($alias, $columnName, $propertyName);
} }
foreach ($classMetadata->associationMappings as $associationMapping) { foreach ($classMetadata->associationMappings as $associationMapping) {
if ($associationMapping['isOwningSide'] && $associationMapping['type'] & ClassMetadataInfo::TO_ONE) { if ($associationMapping['isOwningSide'] && $associationMapping['type'] & ClassMetadataInfo::TO_ONE) {
$targetClass = $this->em->getClassMetadata($associationMapping['targetEntity']);
foreach ($associationMapping['joinColumns'] as $joinColumn) { foreach ($associationMapping['joinColumns'] as $joinColumn) {
$columnName = $joinColumn['name']; $columnName = $joinColumn['name'];
$this->addMetaResult($alias, $columnName, $columnName, $classMetadata->isIdentifier($columnName)); $columnType = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em);
$this->addMetaResult($alias, $columnName, $columnName, $classMetadata->isIdentifier($columnName), $columnType);
} }
} }
} }
@ -318,8 +326,8 @@ class ResultSetMappingBuilder extends ResultSetMapping
{ {
$counter = 0; $counter = 0;
$resultMapping = $class->getSqlResultSetMapping($resultSetMappingName); $resultMapping = $class->getSqlResultSetMapping($resultSetMappingName);
$rooShortName = $class->reflClass->getShortName(); $rootShortName = $class->reflClass->getShortName();
$rootAlias = strtolower($rooShortName[0]) . $counter; $rootAlias = strtolower($rootShortName[0]) . $counter;
if (isset($resultMapping['entities'])) { if (isset($resultMapping['entities'])) {
@ -334,9 +342,10 @@ class ResultSetMappingBuilder extends ResultSetMapping
$joinAlias = strtolower($shortName[0]) . ++ $counter; $joinAlias = strtolower($shortName[0]) . ++ $counter;
$associations = $class->getAssociationsByTargetClass($classMetadata->name); $associations = $class->getAssociationsByTargetClass($classMetadata->name);
$this->addNamedNativeQueryEntityResultMapping($classMetadata, $entityMapping, $joinAlias);
foreach ($associations as $relation => $mapping) { foreach ($associations as $relation => $mapping) {
$this->addJoinedEntityResult($mapping['targetEntity'], $joinAlias, $rootAlias, $relation); $this->addJoinedEntityResult($mapping['targetEntity'], $joinAlias, $rootAlias, $relation);
$this->addNamedNativeQueryEntityResultMapping($classMetadata, $entityMapping, $joinAlias);
} }
} }
@ -345,7 +354,11 @@ class ResultSetMappingBuilder extends ResultSetMapping
if (isset($resultMapping['columns'])) { if (isset($resultMapping['columns'])) {
foreach ($resultMapping['columns'] as $entityMapping) { foreach ($resultMapping['columns'] as $entityMapping) {
$this->addScalarResult($entityMapping['name'], $entityMapping['name']); $type = isset($class->fieldNames[$entityMapping['name']])
? PersisterHelper::getTypeOfColumn($entityMapping['name'], $class, $this->em)
: 'string';
$this->addScalarResult($entityMapping['name'], $entityMapping['name'], $type);
} }
} }
@ -361,14 +374,17 @@ class ResultSetMappingBuilder extends ResultSetMapping
* *
* @return ResultSetMappingBuilder * @return ResultSetMappingBuilder
* *
* @throws MappingException
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
public function addNamedNativeQueryEntityResultMapping(ClassMetadataInfo $classMetadata, array $entityMapping, $alias) public function addNamedNativeQueryEntityResultMapping(ClassMetadataInfo $classMetadata, array $entityMapping, $alias)
{ {
if (isset($entityMapping['discriminatorColumn']) && $entityMapping['discriminatorColumn']) { if (isset($entityMapping['discriminatorColumn']) && $entityMapping['discriminatorColumn']) {
$discriminatorColumn = $entityMapping['discriminatorColumn']; $discriminatorColumn = $entityMapping['discriminatorColumn'];
$discriminatorType = $classMetadata->discriminatorColumn['type'];
$this->setDiscriminatorColumn($alias, $discriminatorColumn); $this->setDiscriminatorColumn($alias, $discriminatorColumn);
$this->addMetaResult($alias, $discriminatorColumn, $discriminatorColumn); $this->addMetaResult($alias, $discriminatorColumn, $discriminatorColumn, false, $discriminatorType);
} }
if (isset($entityMapping['fields']) && !empty($entityMapping['fields'])) { if (isset($entityMapping['fields']) && !empty($entityMapping['fields'])) {
@ -376,25 +392,26 @@ class ResultSetMappingBuilder extends ResultSetMapping
$fieldName = $field['name']; $fieldName = $field['name'];
$relation = null; $relation = null;
if(strpos($fieldName, '.')){ if (strpos($fieldName, '.') !== false) {
list($relation, $fieldName) = explode('.', $fieldName); list($relation, $fieldName) = explode('.', $fieldName);
} }
if (isset($classMetadata->associationMappings[$relation])) { if (isset($classMetadata->associationMappings[$relation])) {
if($relation) { if ($relation) {
$associationMapping = $classMetadata->associationMappings[$relation]; $associationMapping = $classMetadata->associationMappings[$relation];
$joinAlias = $alias.$relation; $joinAlias = $alias.$relation;
$parentAlias = $alias; $parentAlias = $alias;
$this->addJoinedEntityResult($associationMapping['targetEntity'], $joinAlias, $parentAlias, $relation); $this->addJoinedEntityResult($associationMapping['targetEntity'], $joinAlias, $parentAlias, $relation);
$this->addFieldResult($joinAlias, $field['column'], $fieldName); $this->addFieldResult($joinAlias, $field['column'], $fieldName);
}else { } else {
$this->addFieldResult($alias, $field['column'], $fieldName, $classMetadata->name); $this->addFieldResult($alias, $field['column'], $fieldName, $classMetadata->name);
} }
} else { } else {
if(!isset($classMetadata->fieldMappings[$fieldName])) { if( ! isset($classMetadata->fieldMappings[$fieldName])) {
throw new \InvalidArgumentException("Entity '".$classMetadata->name."' has no field '".$fieldName."'. "); throw new \InvalidArgumentException("Entity '".$classMetadata->name."' has no field '".$fieldName."'. ");
} }
$this->addFieldResult($alias, $field['column'], $fieldName, $classMetadata->name); $this->addFieldResult($alias, $field['column'], $fieldName, $classMetadata->name);
} }
} }
@ -402,6 +419,7 @@ class ResultSetMappingBuilder extends ResultSetMapping
} else { } else {
foreach ($classMetadata->getColumnNames() as $columnName) { foreach ($classMetadata->getColumnNames() as $columnName) {
$propertyName = $classMetadata->getFieldName($columnName); $propertyName = $classMetadata->getFieldName($columnName);
$this->addFieldResult($alias, $columnName, $propertyName); $this->addFieldResult($alias, $columnName, $propertyName);
} }
} }

View File

@ -22,9 +22,10 @@ namespace Doctrine\ORM\Query;
use Doctrine\DBAL\LockMode; use Doctrine\DBAL\LockMode;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Query;
use Doctrine\ORM\OptimisticLockException;
use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\ORM\Mapping\ClassMetadataInfo;
use Doctrine\ORM\OptimisticLockException;
use Doctrine\ORM\Query;
use Doctrine\ORM\Utility\PersisterHelper;
/** /**
* The SqlWalker is a TreeWalker that walks over a DQL AST and constructs * The SqlWalker is a TreeWalker that walks over a DQL AST and constructs
@ -456,8 +457,11 @@ class SqlWalker implements TreeWalker
$values[] = $conn->quote($this->em->getClassMetadata($subclassName)->discriminatorValue); $values[] = $conn->quote($this->em->getClassMetadata($subclassName)->discriminatorValue);
} }
$sqlParts[] = (($this->useSqlTableAliases) ? $this->getSQLTableAlias($class->getTableName(), $dqlAlias) . '.' : '') $sqlTableAlias = ($this->useSqlTableAliases)
. $class->discriminatorColumn['name'] . ' IN (' . implode(', ', $values) . ')'; ? $this->getSQLTableAlias($class->getTableName(), $dqlAlias) . '.'
: '';
$sqlParts[] = $sqlTableAlias . $class->discriminatorColumn['name'] . ' IN (' . implode(', ', $values) . ')';
} }
$sql = implode(' AND ', $sqlParts); $sql = implode(' AND ', $sqlParts);
@ -735,7 +739,7 @@ class SqlWalker implements TreeWalker
$sqlSelectExpressions[] = $tblAlias . '.' . $discrColumn['name'] . ' AS ' . $columnAlias; $sqlSelectExpressions[] = $tblAlias . '.' . $discrColumn['name'] . ' AS ' . $columnAlias;
$this->rsm->setDiscriminatorColumn($dqlAlias, $columnAlias); $this->rsm->setDiscriminatorColumn($dqlAlias, $columnAlias);
$this->rsm->addMetaResult($dqlAlias, $columnAlias, $discrColumn['fieldName']); $this->rsm->addMetaResult($dqlAlias, $columnAlias, $discrColumn['fieldName'], false, $discrColumn['type']);
} }
// Add foreign key columns to SQL, if necessary // Add foreign key columns to SQL, if necessary
@ -751,23 +755,19 @@ class SqlWalker implements TreeWalker
continue; continue;
} }
$targetClass = $this->em->getClassMetadata($assoc['targetEntity']);
$isIdentifier = (isset($assoc['id']) && $assoc['id'] === true);
$owningClass = (isset($assoc['inherited'])) ? $this->em->getClassMetadata($assoc['inherited']) : $class; $owningClass = (isset($assoc['inherited'])) ? $this->em->getClassMetadata($assoc['inherited']) : $class;
$sqlTableAlias = $this->getSQLTableAlias($owningClass->getTableName(), $dqlAlias); $sqlTableAlias = $this->getSQLTableAlias($owningClass->getTableName(), $dqlAlias);
$targetClass = $this->em->getClassMetadata($assoc['targetEntity']); foreach ($assoc['joinColumns'] as $joinColumn) {
$columnName = $joinColumn['name'];
$columnAlias = $this->getSQLColumnAlias($columnName);
$columnType = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em);
foreach ($assoc['targetToSourceKeyColumns'] as $targetColumn => $srcColumn) { $sqlSelectExpressions[] = $sqlTableAlias . '.' . $columnName . ' AS ' . $columnAlias;
$columnAlias = $this->getSQLColumnAlias($srcColumn);
$type = null; $this->rsm->addMetaResult($dqlAlias, $columnAlias, $columnName, $isIdentifier, $columnType);
$isIdentifier = (isset($assoc['id']) && $assoc['id'] === true);
$sqlSelectExpressions[] = $sqlTableAlias . '.' . $srcColumn . ' AS ' . $columnAlias;
if (isset($targetClass->fieldNames[$targetColumn])) {
$type = $targetClass->fieldMappings[$targetClass->fieldNames[$targetColumn]]['type'];
}
$this->rsm->addMetaResult($dqlAlias, $columnAlias, $srcColumn, $isIdentifier, $type);
} }
} }
@ -785,14 +785,18 @@ class SqlWalker implements TreeWalker
// Skip if association is inherited // Skip if association is inherited
if (isset($assoc['inherited'])) continue; if (isset($assoc['inherited'])) continue;
if ( ! ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE)) continue; if ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE) {
$targetClass = $this->em->getClassMetadata($assoc['targetEntity']);
foreach ($assoc['targetToSourceKeyColumns'] as $srcColumn) { foreach ($assoc['joinColumns'] as $joinColumn) {
$columnAlias = $this->getSQLColumnAlias($srcColumn); $columnName = $joinColumn['name'];
$columnAlias = $this->getSQLColumnAlias($columnName);
$columnType = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em);
$sqlSelectExpressions[] = $sqlTableAlias . '.' . $srcColumn . ' AS ' . $columnAlias; $sqlSelectExpressions[] = $sqlTableAlias . '.' . $columnName . ' AS ' . $columnAlias;
$this->rsm->addMetaResult($dqlAlias, $columnAlias, $srcColumn); $this->rsm->addMetaResult($dqlAlias, $columnAlias, $columnName, $subClass->isIdentifier($columnName), $columnType);
}
} }
} }
} }
@ -1296,15 +1300,13 @@ class SqlWalker implements TreeWalker
: $class->getTableName(); : $class->getTableName();
$sqlTableAlias = $this->getSQLTableAlias($tableName, $dqlAlias); $sqlTableAlias = $this->getSQLTableAlias($tableName, $dqlAlias);
$fieldMapping = $class->fieldMappings[$fieldName];
$columnName = $this->quoteStrategy->getColumnName($fieldName, $class, $this->platform); $columnName = $this->quoteStrategy->getColumnName($fieldName, $class, $this->platform);
$columnAlias = $this->getSQLColumnAlias($class->fieldMappings[$fieldName]['columnName']); $columnAlias = $this->getSQLColumnAlias($fieldMapping['columnName']);
$col = $sqlTableAlias . '.' . $columnName; $col = $sqlTableAlias . '.' . $columnName;
$fieldType = $class->getTypeOfField($fieldName); if (isset($fieldMapping['requireSQLConversion'])) {
$type = Type::getType($fieldMapping['type']);
if (isset($class->fieldMappings[$fieldName]['requireSQLConversion'])) {
$type = Type::getType($fieldType);
$col = $type->convertToPHPValueSQL($col, $this->conn->getDatabasePlatform()); $col = $type->convertToPHPValueSQL($col, $this->conn->getDatabasePlatform());
} }
@ -1313,9 +1315,10 @@ class SqlWalker implements TreeWalker
$this->scalarResultAliasMap[$resultAlias] = $columnAlias; $this->scalarResultAliasMap[$resultAlias] = $columnAlias;
if ( ! $hidden) { if ( ! $hidden) {
$this->rsm->addScalarResult($columnAlias, $resultAlias, $fieldType); $this->rsm->addScalarResult($columnAlias, $resultAlias, $fieldMapping['type']);
$this->scalarFields[$dqlAlias][$fieldName] = $columnAlias; $this->scalarFields[$dqlAlias][$fieldName] = $columnAlias;
} }
break; break;
case ($expr instanceof AST\AggregateExpression): case ($expr instanceof AST\AggregateExpression):
@ -1400,8 +1403,8 @@ class SqlWalker implements TreeWalker
$col = $sqlTableAlias . '.' . $quotedColumnName; $col = $sqlTableAlias . '.' . $quotedColumnName;
if (isset($class->fieldMappings[$fieldName]['requireSQLConversion'])) { if (isset($mapping['requireSQLConversion'])) {
$type = Type::getType($class->getTypeOfField($fieldName)); $type = Type::getType($mapping['type']);
$col = $type->convertToPHPValueSQL($col, $this->platform); $col = $type->convertToPHPValueSQL($col, $this->platform);
} }
@ -1422,7 +1425,7 @@ class SqlWalker implements TreeWalker
$sqlTableAlias = $this->getSQLTableAlias($subClass->getTableName(), $dqlAlias); $sqlTableAlias = $this->getSQLTableAlias($subClass->getTableName(), $dqlAlias);
foreach ($subClass->fieldMappings as $fieldName => $mapping) { foreach ($subClass->fieldMappings as $fieldName => $mapping) {
if (isset($mapping['inherited']) || $partialFieldSet && !in_array($fieldName, $partialFieldSet)) { if (isset($mapping['inherited']) || ($partialFieldSet && !in_array($fieldName, $partialFieldSet))) {
continue; continue;
} }
@ -1431,8 +1434,8 @@ class SqlWalker implements TreeWalker
$col = $sqlTableAlias . '.' . $quotedColumnName; $col = $sqlTableAlias . '.' . $quotedColumnName;
if (isset($subClass->fieldMappings[$fieldName]['requireSQLConversion'])) { if (isset($mapping['requireSQLConversion'])) {
$type = Type::getType($subClass->getTypeOfField($fieldName)); $type = Type::getType($mapping['type']);
$col = $type->convertToPHPValueSQL($col, $this->platform); $col = $type->convertToPHPValueSQL($col, $this->platform);
} }
@ -1543,11 +1546,10 @@ class SqlWalker implements TreeWalker
break; break;
case ($e instanceof AST\PathExpression): case ($e instanceof AST\PathExpression):
$fieldName = $e->field;
$dqlAlias = $e->identificationVariable; $dqlAlias = $e->identificationVariable;
$qComp = $this->queryComponents[$dqlAlias]; $qComp = $this->queryComponents[$dqlAlias];
$class = $qComp['metadata']; $class = $qComp['metadata'];
$fieldType = $class->getTypeOfField($fieldName); $fieldType = $class->fieldMappings[$e->field]['type'];
$sqlSelectExpressions[] = trim($e->dispatch($this)) . ' AS ' . $columnAlias; $sqlSelectExpressions[] = trim($e->dispatch($this)) . ' AS ' . $columnAlias;
break; break;

View File

@ -89,7 +89,7 @@ class LimitSubqueryWalker extends TreeWalkerAdapter
$this->_getQuery()->setHint( $this->_getQuery()->setHint(
self::IDENTIFIER_TYPE, self::IDENTIFIER_TYPE,
Type::getType($rootClass->getTypeOfField($identifier)) Type::getType($rootClass->fieldMappings[$identifier]['type'])
); );
$pathExpression = new PathExpression( $pathExpression = new PathExpression(
@ -97,9 +97,11 @@ class LimitSubqueryWalker extends TreeWalkerAdapter
$rootAlias, $rootAlias,
$identifier $identifier
); );
$pathExpression->type = PathExpression::TYPE_STATE_FIELD; $pathExpression->type = PathExpression::TYPE_STATE_FIELD;
array_unshift($selectExpressions, new SelectExpression($pathExpression, '_dctrn_id')); array_unshift($selectExpressions, new SelectExpression($pathExpression, '_dctrn_id'));
$AST->selectClause->selectExpressions = $selectExpressions; $AST->selectClause->selectExpressions = $selectExpressions;
if (isset($AST->orderByClause)) { if (isset($AST->orderByClause)) {

View File

@ -26,7 +26,7 @@ namespace Doctrine\Tests\Models\DDC869;
class DDC869ChequePayment extends DDC869Payment class DDC869ChequePayment extends DDC869Payment
{ {
/** @column(type="string") */ /** @Column(type="string") */
protected $serialNumber; protected $serialNumber;
public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)

View File

@ -26,7 +26,7 @@ namespace Doctrine\Tests\Models\DDC869;
class DDC869CreditCardPayment extends DDC869Payment class DDC869CreditCardPayment extends DDC869Payment
{ {
/** @column(type="string") */ /** @Column(type="string") */
protected $creditCardNumber; protected $creditCardNumber;
public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)

View File

@ -33,7 +33,7 @@ class DDC869Payment
*/ */
protected $id; protected $id;
/** @column(type="float") */ /** @Column(type="float") */
protected $value; protected $value;

View File

@ -23,7 +23,7 @@ use Doctrine\Common\Collections\ArrayCollection;
*/ */
class DDC964Admin extends DDC964User class DDC964Admin extends DDC964User
{ {
public static function loadMetadata($metadata) public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
{ {
$metadata->setAssociationOverride('address',array( $metadata->setAssociationOverride('address',array(
'joinColumns'=>array(array( 'joinColumns'=>array(array(

View File

@ -26,7 +26,7 @@ use Doctrine\Common\Collections\ArrayCollection;
*/ */
class DDC964Guest extends DDC964User class DDC964Guest extends DDC964User
{ {
public static function loadMetadata($metadata) public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
{ {
$metadata->setAttributeOverride('id', array( $metadata->setAttributeOverride('id', array(
'columnName' => 'guest_id', 'columnName' => 'guest_id',

View File

@ -107,7 +107,7 @@ class DDC964User
$this->address = $address; $this->address = $address;
} }
public static function loadMetadata($metadata) public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
{ {
$metadata->mapField(array( $metadata->mapField(array(
'id' => true, 'id' => true,

View File

@ -0,0 +1,30 @@
<?php
namespace Doctrine\Tests\Models\Generic;
/**
* @Entity
* @Table(name="`not-a-simple-entity`")
*/
class NonAlphaColumnsEntity
{
/**
* @Id
* @Column(type="integer", name="`simple-entity-id`")
* @GeneratedValue(strategy="AUTO")
*/
public $id;
/**
* @Column(type="string", name="`simple-entity-value`")
*/
public $value;
/**
* @param string $value
*/
public function __construct($value)
{
$this->value = $value;
}
}

View File

@ -1,19 +1,19 @@
<?php <?php
/** /**
* @entity * @Entity
* @table(name="articles") * @Table(name="articles")
*/ */
class DoctrineGlobal_Article class DoctrineGlobal_Article
{ {
/** /**
* @id * @Id
* @column(type="int") * @Column(type="integer")
*/ */
protected $id; protected $id;
/** /**
* @column(type="string") * @Column(type="string")
*/ */
protected $headline; protected $headline;
@ -32,7 +32,7 @@ class DoctrineGlobal_Article
protected $author; protected $author;
/** /**
* @ManyToMany(targetEntity="\DoctrineGlobal_User") * @ManyToMany(targetEntity="DoctrineGlobal_User")
* @JoinTable(name="editor_articles", * @JoinTable(name="editor_articles",
* joinColumns={@JoinColumn(name="article_id", referencedColumnName="id")}, * joinColumns={@JoinColumn(name="article_id", referencedColumnName="id")},
* inverseJoinColumns={@JoinColumn(name="editor_id", referencedColumnName="id", unique=true)} * inverseJoinColumns={@JoinColumn(name="editor_id", referencedColumnName="id", unique=true)}
@ -49,19 +49,22 @@ class DoctrineGlobal_User
{ {
/** /**
* @Id * @Id
* @column(type="integer") * @Column(type="integer")
*
* @var int * @var int
*/ */
private $id; private $id;
/** /**
* @column(type="string", length=64) * @Column(type="string", length=64)
*
* @var string * @var string
*/ */
private $username; private $username;
/** /**
* @column(type="string", length=128) * @Column(type="string", length=128)
*
* @var string * @var string
*/ */
private $email; private $email;

View File

@ -492,7 +492,7 @@ class DefaultQueryCacheTest extends OrmTestCase
$key = new QueryCacheKey('query.key1', 0); $key = new QueryCacheKey('query.key1', 0);
$rsm = new ResultSetMappingBuilder($this->em); $rsm = new ResultSetMappingBuilder($this->em);
$rsm->addScalarResult('id', 'u'); $rsm->addScalarResult('id', 'u', 'integer');
$this->queryCache->put($key, $rsm, $result); $this->queryCache->put($key, $rsm, $result);
} }

View File

@ -58,12 +58,16 @@ class DetachedEntityTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->persist($user); $this->_em->persist($user);
$this->_em->flush(); $this->_em->flush();
$this->assertTrue($this->_em->contains($user)); $this->assertTrue($this->_em->contains($user));
$this->assertTrue($user->phonenumbers->isInitialized()); $this->assertTrue($user->phonenumbers->isInitialized());
$serialized = serialize($user); $serialized = serialize($user);
$this->_em->clear(); $this->_em->clear();
$this->assertFalse($this->_em->contains($user)); $this->assertFalse($this->_em->contains($user));
unset($user); unset($user);
$user = unserialize($serialized); $user = unserialize($serialized);
@ -71,9 +75,12 @@ class DetachedEntityTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertEquals(1, count($user->getPhonenumbers()), "Pre-Condition: 1 Phonenumber"); $this->assertEquals(1, count($user->getPhonenumbers()), "Pre-Condition: 1 Phonenumber");
$ph2 = new CmsPhonenumber; $ph2 = new CmsPhonenumber;
$ph2->phonenumber = "56789"; $ph2->phonenumber = "56789";
$user->addPhonenumber($ph2); $user->addPhonenumber($ph2);
$oldPhonenumbers = $user->getPhonenumbers(); $oldPhonenumbers = $user->getPhonenumbers();
$this->assertEquals(2, count($oldPhonenumbers), "Pre-Condition: 2 Phonenumbers"); $this->assertEquals(2, count($oldPhonenumbers), "Pre-Condition: 2 Phonenumbers");
$this->assertFalse($this->_em->contains($user)); $this->assertFalse($this->_em->contains($user));

View File

@ -32,8 +32,10 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
public function testJoinedChildInsertSetsInitialVersionValue() public function testJoinedChildInsertSetsInitialVersionValue()
{ {
$test = new OptimisticJoinedChild(); $test = new OptimisticJoinedChild();
$test->name = 'child'; $test->name = 'child';
$test->whatever = 'whatever'; $test->whatever = 'whatever';
$this->_em->persist($test); $this->_em->persist($test);
$this->_em->flush(); $this->_em->flush();
@ -48,7 +50,9 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
public function testJoinedChildFailureThrowsException(OptimisticJoinedChild $child) public function testJoinedChildFailureThrowsException(OptimisticJoinedChild $child)
{ {
$q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticJoinedChild t WHERE t.id = :id'); $q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticJoinedChild t WHERE t.id = :id');
$q->setParameter('id', $child->id); $q->setParameter('id', $child->id);
$test = $q->getSingleResult(); $test = $q->getSingleResult();
// Manually update/increment the version so we can try and save the same // Manually update/increment the version so we can try and save the same
@ -58,6 +62,7 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
// Now lets change a property and try and save it again // Now lets change a property and try and save it again
$test->whatever = 'ok'; $test->whatever = 'ok';
try { try {
$this->_em->flush(); $this->_em->flush();
} catch (OptimisticLockException $e) { } catch (OptimisticLockException $e) {
@ -68,7 +73,9 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
public function testJoinedParentInsertSetsInitialVersionValue() public function testJoinedParentInsertSetsInitialVersionValue()
{ {
$test = new OptimisticJoinedParent(); $test = new OptimisticJoinedParent();
$test->name = 'parent'; $test->name = 'parent';
$this->_em->persist($test); $this->_em->persist($test);
$this->_em->flush(); $this->_em->flush();
@ -83,7 +90,9 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
public function testJoinedParentFailureThrowsException(OptimisticJoinedParent $parent) public function testJoinedParentFailureThrowsException(OptimisticJoinedParent $parent)
{ {
$q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticJoinedParent t WHERE t.id = :id'); $q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticJoinedParent t WHERE t.id = :id');
$q->setParameter('id', $parent->id); $q->setParameter('id', $parent->id);
$test = $q->getSingleResult(); $test = $q->getSingleResult();
// Manually update/increment the version so we can try and save the same // Manually update/increment the version so we can try and save the same
@ -93,6 +102,7 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
// Now lets change a property and try and save it again // Now lets change a property and try and save it again
$test->name = 'WHATT???'; $test->name = 'WHATT???';
try { try {
$this->_em->flush(); $this->_em->flush();
} catch (OptimisticLockException $e) { } catch (OptimisticLockException $e) {
@ -106,6 +116,7 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
for ($i = 0; $i < 5; $i++) { for ($i = 0; $i < 5; $i++) {
$test->name = 'test' . $i; $test->name = 'test' . $i;
$this->_em->persist($test); $this->_em->persist($test);
$this->_em->flush(); $this->_em->flush();
@ -117,7 +128,9 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
public function testStandardInsertSetsInitialVersionValue() public function testStandardInsertSetsInitialVersionValue()
{ {
$test = new OptimisticStandard(); $test = new OptimisticStandard();
$test->name = 'test'; $test->name = 'test';
$this->_em->persist($test); $this->_em->persist($test);
$this->_em->flush(); $this->_em->flush();
@ -133,7 +146,9 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
public function testStandardFailureThrowsException(OptimisticStandard $entity) public function testStandardFailureThrowsException(OptimisticStandard $entity)
{ {
$q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticStandard t WHERE t.id = :id'); $q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticStandard t WHERE t.id = :id');
$q->setParameter('id', $entity->id); $q->setParameter('id', $entity->id);
$test = $q->getSingleResult(); $test = $q->getSingleResult();
// Manually update/increment the version so we can try and save the same // Manually update/increment the version so we can try and save the same
@ -143,6 +158,7 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
// Now lets change a property and try and save it again // Now lets change a property and try and save it again
$test->name = 'WHATT???'; $test->name = 'WHATT???';
try { try {
$this->_em->flush(); $this->_em->flush();
} catch (OptimisticLockException $e) { } catch (OptimisticLockException $e) {
@ -153,7 +169,9 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
public function testLockWorksWithProxy() public function testLockWorksWithProxy()
{ {
$test = new OptimisticStandard(); $test = new OptimisticStandard();
$test->name = 'test'; $test->name = 'test';
$this->_em->persist($test); $this->_em->persist($test);
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
@ -166,6 +184,7 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
public function testOptimisticTimestampSetsDefaultValue() public function testOptimisticTimestampSetsDefaultValue()
{ {
$test = new OptimisticTimestamp(); $test = new OptimisticTimestamp();
$test->name = 'Testing'; $test->name = 'Testing';
$this->assertNull($test->version, "Pre-Condition"); $this->assertNull($test->version, "Pre-Condition");
@ -184,18 +203,22 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
public function testOptimisticTimestampFailureThrowsException(OptimisticTimestamp $entity) public function testOptimisticTimestampFailureThrowsException(OptimisticTimestamp $entity)
{ {
$q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticTimestamp t WHERE t.id = :id'); $q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticTimestamp t WHERE t.id = :id');
$q->setParameter('id', $entity->id); $q->setParameter('id', $entity->id);
$test = $q->getSingleResult(); $test = $q->getSingleResult();
$this->assertInstanceOf('DateTime', $test->version); $this->assertInstanceOf('DateTime', $test->version);
// Manually increment the version datetime column // Manually increment the version datetime column
$format = $this->_em->getConnection()->getDatabasePlatform()->getDateTimeFormatString(); $format = $this->_em->getConnection()->getDatabasePlatform()->getDateTimeFormatString();
$this->_conn->executeQuery('UPDATE optimistic_timestamp SET version = ? WHERE id = ?', array(date($format, strtotime($test->version->format($format)) + 3600), $test->id)); $this->_conn->executeQuery('UPDATE optimistic_timestamp SET version = ? WHERE id = ?', array(date($format, strtotime($test->version->format($format)) + 3600), $test->id));
// Try and update the record and it should throw an exception // Try and update the record and it should throw an exception
$caughtException = null; $caughtException = null;
$test->name = 'Testing again'; $test->name = 'Testing again';
try { try {
$this->_em->flush(); $this->_em->flush();
} catch (OptimisticLockException $e) { } catch (OptimisticLockException $e) {
@ -213,15 +236,19 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
public function testOptimisticTimestampLockFailureThrowsException(OptimisticTimestamp $entity) public function testOptimisticTimestampLockFailureThrowsException(OptimisticTimestamp $entity)
{ {
$q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticTimestamp t WHERE t.id = :id'); $q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticTimestamp t WHERE t.id = :id');
$q->setParameter('id', $entity->id); $q->setParameter('id', $entity->id);
$test = $q->getSingleResult(); $test = $q->getSingleResult();
$this->assertInstanceOf('DateTime', $test->version); $this->assertInstanceOf('DateTime', $test->version);
// Try to lock the record with an older timestamp and it should throw an exception // Try to lock the record with an older timestamp and it should throw an exception
$caughtException = null; $caughtException = null;
try { try {
$expectedVersionExpired = DateTime::createFromFormat('U', $test->version->getTimestamp()-3600); $expectedVersionExpired = DateTime::createFromFormat('U', $test->version->getTimestamp()-3600);
$this->_em->lock($test, LockMode::OPTIMISTIC, $expectedVersionExpired); $this->_em->lock($test, LockMode::OPTIMISTIC, $expectedVersionExpired);
} catch (OptimisticLockException $e) { } catch (OptimisticLockException $e) {
$caughtException = $e; $caughtException = $e;
@ -294,7 +321,10 @@ class OptimisticStandard
*/ */
private $version; private $version;
function getVersion() {return $this->version;} public function getVersion()
{
return $this->version;
}
} }
/** /**

View File

@ -7,13 +7,10 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\ORM\Query\ResultSetMappingBuilder; use Doctrine\ORM\Query\ResultSetMappingBuilder;
use Doctrine\ORM\Query\Parameter; use Doctrine\ORM\Query\Parameter;
use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\CMS\CmsUser;
use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsPhonenumber;
use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsAddress;
use Doctrine\Tests\Models\CMS\CmsEmail; use Doctrine\Tests\Models\CMS\CmsEmail;
use Doctrine\Tests\Models\CMS\CmsArticle;
use Doctrine\Tests\Models\Company\CompanyFixContract;
use Doctrine\Tests\Models\Company\CompanyEmployee; use Doctrine\Tests\Models\Company\CompanyEmployee;
use Doctrine\Tests\Models\Company\CompanyPerson; use Doctrine\Tests\Models\Company\CompanyPerson;
@ -85,7 +82,7 @@ class NativeQueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$rsm->addFieldResult('a', $this->platform->getSQLResultCasing('country'), 'country'); $rsm->addFieldResult('a', $this->platform->getSQLResultCasing('country'), 'country');
$rsm->addFieldResult('a', $this->platform->getSQLResultCasing('zip'), 'zip'); $rsm->addFieldResult('a', $this->platform->getSQLResultCasing('zip'), 'zip');
$rsm->addFieldResult('a', $this->platform->getSQLResultCasing('city'), 'city'); $rsm->addFieldResult('a', $this->platform->getSQLResultCasing('city'), 'city');
$rsm->addMetaResult('a', $this->platform->getSQLResultCasing('user_id'), 'user_id'); $rsm->addMetaResult('a', $this->platform->getSQLResultCasing('user_id'), 'user_id', false, 'integer');
$query = $this->_em->createNativeQuery('SELECT a.id, a.country, a.zip, a.city, a.user_id FROM cms_addresses a WHERE a.id = ?', $rsm); $query = $this->_em->createNativeQuery('SELECT a.id, a.country, a.zip, a.city, a.user_id FROM cms_addresses a WHERE a.id = ?', $rsm);
$query->setParameter(1, $addr->id); $query->setParameter(1, $addr->id);

View File

@ -37,13 +37,14 @@ class ResultCacheTest extends \Doctrine\Tests\OrmFunctionalTestCase
public function testResultCache() public function testResultCache()
{ {
$user = new CmsUser; $user = new CmsUser;
$user->name = 'Roman'; $user->name = 'Roman';
$user->username = 'romanb'; $user->username = 'romanb';
$user->status = 'dev'; $user->status = 'dev';
$this->_em->persist($user); $this->_em->persist($user);
$this->_em->flush(); $this->_em->flush();
$query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux'); $query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux');
$cache = new ArrayCache(); $cache = new ArrayCache();
@ -73,8 +74,8 @@ class ResultCacheTest extends \Doctrine\Tests\OrmFunctionalTestCase
public function testSetResultCacheId() public function testSetResultCacheId()
{ {
$cache = new ArrayCache; $cache = new ArrayCache;
$query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux'); $query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux');
$query->setResultCacheDriver($cache); $query->setResultCacheDriver($cache);
$query->setResultCacheId('testing_result_cache_id'); $query->setResultCacheId('testing_result_cache_id');
@ -87,9 +88,9 @@ class ResultCacheTest extends \Doctrine\Tests\OrmFunctionalTestCase
public function testUseResultCache() public function testUseResultCache()
{ {
$cache = new \Doctrine\Common\Cache\ArrayCache(); $cache = new ArrayCache();
$query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux'); $query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux');
$query->useResultCache(true); $query->useResultCache(true);
$query->setResultCacheDriver($cache); $query->setResultCacheDriver($cache);
$query->setResultCacheId('testing_result_cache_id'); $query->setResultCacheId('testing_result_cache_id');
@ -105,10 +106,10 @@ class ResultCacheTest extends \Doctrine\Tests\OrmFunctionalTestCase
*/ */
public function testUseResultCacheParams() public function testUseResultCacheParams()
{ {
$cache = new \Doctrine\Common\Cache\ArrayCache(); $cache = new ArrayCache();
$sqlCount = count($this->_sqlLoggerStack->queries); $sqlCount = count($this->_sqlLoggerStack->queries);
$query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux WHERE ux.id = ?1'); $query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux WHERE ux.id = ?1');
$query->setParameter(1, 1); $query->setParameter(1, 1);
$query->setResultCacheDriver($cache); $query->setResultCacheDriver($cache);
$query->useResultCache(true); $query->useResultCache(true);
@ -131,16 +132,20 @@ class ResultCacheTest extends \Doctrine\Tests\OrmFunctionalTestCase
public function testNativeQueryResultCaching() public function testNativeQueryResultCaching()
{ {
$rsm = new \Doctrine\ORM\Query\ResultSetMapping();
$rsm->addScalarResult('id', 'u');
$query = $this->_em->createNativeQuery('select u.id FROM cms_users u WHERE u.id = ?', $rsm);
$query->setParameter(1, 10);
$cache = new ArrayCache(); $cache = new ArrayCache();
$rsm = new \Doctrine\ORM\Query\ResultSetMapping();
$rsm->addScalarResult('id', 'u', 'integer');
$query = $this->_em->createNativeQuery('select u.id FROM cms_users u WHERE u.id = ?', $rsm);
$query->setParameter(1, 10);
$query->setResultCacheDriver($cache)->useResultCache(true); $query->setResultCacheDriver($cache)->useResultCache(true);
$this->assertEquals(0, $this->getCacheSize($cache)); $this->assertEquals(0, $this->getCacheSize($cache));
$query->getResult(); $query->getResult();
$this->assertEquals(1, $this->getCacheSize($cache)); $this->assertEquals(1, $this->getCacheSize($cache));
return $query; return $query;

View File

@ -10,15 +10,12 @@ use Doctrine\Common\Cache\ArrayCache;
use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\ORM\Mapping\ClassMetadataInfo;
use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\CMS\CmsUser;
use Doctrine\Tests\Models\CMS\CmsPhonenumber;
use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsAddress;
use Doctrine\Tests\Models\CMS\CmsGroup; use Doctrine\Tests\Models\CMS\CmsGroup;
use Doctrine\Tests\Models\CMS\CmsArticle; use Doctrine\Tests\Models\CMS\CmsArticle;
use Doctrine\Tests\Models\CMS\CmsComment;
use Doctrine\Tests\Models\Company\CompanyPerson; use Doctrine\Tests\Models\Company\CompanyPerson;
use Doctrine\Tests\Models\Company\CompanyManager; use Doctrine\Tests\Models\Company\CompanyManager;
use Doctrine\Tests\Models\Company\CompanyEmployee;
use Doctrine\Tests\Models\Company\CompanyOrganization; use Doctrine\Tests\Models\Company\CompanyOrganization;
use Doctrine\Tests\Models\Company\CompanyAuction; use Doctrine\Tests\Models\Company\CompanyAuction;

View File

@ -12,7 +12,9 @@ class DDC1050Test extends \Doctrine\Tests\OrmFunctionalTestCase
public function setUp() public function setUp()
{ {
$this->markTestSkipped('performance skipped'); $this->markTestSkipped('performance skipped');
$this->useModelSet('cms'); $this->useModelSet('cms');
parent::setUp(); parent::setUp();
} }

View File

@ -12,6 +12,7 @@ class DDC1655Test extends \Doctrine\Tests\OrmFunctionalTestCase
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
try { try {
$this->_schemaTool->createSchema(array( $this->_schemaTool->createSchema(array(
$this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1655Foo'), $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1655Foo'),
@ -19,7 +20,6 @@ class DDC1655Test extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1655Baz'), $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1655Baz'),
)); ));
} catch(\Exception $e) { } catch(\Exception $e) {
} }
} }

View File

@ -29,7 +29,7 @@ class DDC1695Test extends \Doctrine\Tests\OrmFunctionalTestCase
class DDC1695News class DDC1695News
{ {
/** /**
* @var int $idNews * @var int
* *
* @Column(name="`IdNews`", type="integer", nullable=false) * @Column(name="`IdNews`", type="integer", nullable=false)
* @Id * @Id
@ -38,119 +38,119 @@ class DDC1695News
private $idNews; private $idNews;
/** /**
* @var bigint $iduser * @var int
* *
* @Column(name="`IdUser`", type="bigint", nullable=false) * @Column(name="`IdUser`", type="bigint", nullable=false)
*/ */
private $idUser; private $idUser;
/** /**
* @var int $idLanguage * @var int
* *
* @Column(name="`IdLanguage`", type="integer", nullable=false) * @Column(name="`IdLanguage`", type="integer", nullable=false)
*/ */
private $idLanguage; private $idLanguage;
/** /**
* @var int $idCondition * @var int
* *
* @Column(name="`IdCondition`", type="integer", nullable=true) * @Column(name="`IdCondition`", type="integer", nullable=true)
*/ */
private $idCondition; private $idCondition;
/** /**
* @var int $idHealthProvider * @var int
* *
* @Column(name="`IdHealthProvider`", type="integer", nullable=true) * @Column(name="`IdHealthProvider`", type="integer", nullable=true)
*/ */
private $idHealthProvider; private $idHealthProvider;
/** /**
* @var int $idSpeciality * @var int
* *
* @Column(name="`IdSpeciality`", type="integer", nullable=true) * @Column(name="`IdSpeciality`", type="integer", nullable=true)
*/ */
private $idSpeciality; private $idSpeciality;
/** /**
* @var int $idMedicineType * @var int
* *
* @Column(name="`IdMedicineType`", type="integer", nullable=true) * @Column(name="`IdMedicineType`", type="integer", nullable=true)
*/ */
private $idMedicineType; private $idMedicineType;
/** /**
* @var int $idTreatment * @var int
* *
* @Column(name="`IdTreatment`", type="integer", nullable=true) * @Column(name="`IdTreatment`", type="integer", nullable=true)
*/ */
private $idTreatment; private $idTreatment;
/** /**
* @var string $title * @var string
* *
* @Column(name="`Title`", type="string", nullable=true) * @Column(name="`Title`", type="string", nullable=true)
*/ */
private $title; private $title;
/** /**
* @var string $smallText * @var string
* *
* @Column(name="`SmallText`", type="string", nullable=true) * @Column(name="`SmallText`", type="string", nullable=true)
*/ */
private $smallText; private $smallText;
/** /**
* @var string $longText * @var string
* *
* @Column(name="`LongText`", type="string", nullable=true) * @Column(name="`LongText`", type="string", nullable=true)
*/ */
private $longText; private $longText;
/** /**
* @var datetimetz $publishDate * @var DateTimeZone
* *
* @Column(name="`PublishDate`", type="datetimetz", nullable=true) * @Column(name="`PublishDate`", type="datetimetz", nullable=true)
*/ */
private $publishDate; private $publishDate;
/** /**
* @var tsvector $idxNews * @var array
* *
* @Column(name="`IdxNews`", type="tsvector", nullable=true) * @Column(name="`IdxNews`", type="json_array", nullable=true)
*/ */
private $idxNews; private $idxNews;
/** /**
* @var bool $highlight * @var bool
* *
* @Column(name="`Highlight`", type="boolean", nullable=false) * @Column(name="`Highlight`", type="boolean", nullable=false)
*/ */
private $highlight; private $highlight;
/** /**
* @var int $order * @var int
* *
* @Column(name="`Order`", type="integer", nullable=false) * @Column(name="`Order`", type="integer", nullable=false)
*/ */
private $order; private $order;
/** /**
* @var bool $deleted * @var bool
* *
* @Column(name="`Deleted`", type="boolean", nullable=false) * @Column(name="`Deleted`", type="boolean", nullable=false)
*/ */
private $deleted; private $deleted;
/** /**
* @var bool $active * @var bool
* *
* @Column(name="`Active`", type="boolean", nullable=false) * @Column(name="`Active`", type="boolean", nullable=false)
*/ */
private $active; private $active;
/** /**
* @var bool $updateToHighlighted * @var bool
* *
* @Column(name="`UpdateToHighlighted`", type="boolean", nullable=true) * @Column(name="`UpdateToHighlighted`", type="boolean", nullable=true)
*/ */

View File

@ -18,7 +18,7 @@ class DDC3634Test extends OrmFunctionalTestCase {
$metadata = $this->_em->getClassMetadata(DDC3634Entity::CLASSNAME); $metadata = $this->_em->getClassMetadata(DDC3634Entity::CLASSNAME);
if (! $metadata->idGenerator->isPostInsertGenerator()) { if ( ! $metadata->idGenerator->isPostInsertGenerator()) {
$this->markTestSkipped('Need a post-insert ID generator in order to make this test work correctly'); $this->markTestSkipped('Need a post-insert ID generator in order to make this test work correctly');
} }

View File

@ -24,6 +24,7 @@ class ArrayHydratorTest extends HydrationTestCase
public function testSimpleEntityQuery() public function testSimpleEntityQuery()
{ {
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
$rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__id', 'id');
$rsm->addFieldResult('u', 'u__name', 'name'); $rsm->addFieldResult('u', 'u__name', 'name');
@ -45,7 +46,6 @@ class ArrayHydratorTest extends HydrationTestCase
$result = $hydrator->hydrateAll($stmt, $rsm); $result = $hydrator->hydrateAll($stmt, $rsm);
$this->assertEquals(2, count($result)); $this->assertEquals(2, count($result));
$this->assertTrue(is_array($result)); $this->assertTrue(is_array($result));
$this->assertEquals(1, $result[0]['id']); $this->assertEquals(1, $result[0]['id']);
@ -64,12 +64,12 @@ class ArrayHydratorTest extends HydrationTestCase
public function testSimpleEntityWithScalarQuery($userEntityKey) public function testSimpleEntityWithScalarQuery($userEntityKey)
{ {
$alias = $userEntityKey ?: 'u'; $alias = $userEntityKey ?: 'u';
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', $alias); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', $alias);
$rsm->addFieldResult($alias, 's__id', 'id'); $rsm->addFieldResult($alias, 's__id', 'id');
$rsm->addFieldResult($alias, 's__name', 'name'); $rsm->addFieldResult($alias, 's__name', 'name');
$rsm->addScalarResult('sclr0', 'nameUpper'); $rsm->addScalarResult('sclr0', 'nameUpper', 'string');
// Faked result set // Faked result set
$resultSet = array( $resultSet = array(
@ -90,7 +90,6 @@ class ArrayHydratorTest extends HydrationTestCase
$result = $hydrator->hydrateAll($stmt, $rsm); $result = $hydrator->hydrateAll($stmt, $rsm);
$this->assertEquals(2, count($result)); $this->assertEquals(2, count($result));
$this->assertTrue(is_array($result)); $this->assertTrue(is_array($result));
$this->assertArrayHasKey('nameUpper', $result[0]); $this->assertArrayHasKey('nameUpper', $result[0]);
@ -117,6 +116,7 @@ class ArrayHydratorTest extends HydrationTestCase
public function testSimpleEntityQueryWithAliasedUserEntity() public function testSimpleEntityQueryWithAliasedUserEntity()
{ {
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', 'user'); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', 'user');
$rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__id', 'id');
$rsm->addFieldResult('u', 'u__name', 'name'); $rsm->addFieldResult('u', 'u__name', 'name');
@ -138,7 +138,6 @@ class ArrayHydratorTest extends HydrationTestCase
$result = $hydrator->hydrateAll($stmt, $rsm); $result = $hydrator->hydrateAll($stmt, $rsm);
$this->assertEquals(2, count($result)); $this->assertEquals(2, count($result));
$this->assertTrue(is_array($result)); $this->assertTrue(is_array($result));
$this->assertArrayHasKey('user', $result[0]); $this->assertArrayHasKey('user', $result[0]);
@ -157,6 +156,7 @@ class ArrayHydratorTest extends HydrationTestCase
public function testSimpleMultipleRootEntityQuery() public function testSimpleMultipleRootEntityQuery()
{ {
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsArticle', 'a'); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsArticle', 'a');
$rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__id', 'id');
@ -206,6 +206,7 @@ class ArrayHydratorTest extends HydrationTestCase
public function testSimpleMultipleRootEntityQueryWithAliasedUserEntity() public function testSimpleMultipleRootEntityQueryWithAliasedUserEntity()
{ {
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', 'user'); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', 'user');
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsArticle', 'a'); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsArticle', 'a');
$rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__id', 'id');
@ -259,6 +260,7 @@ class ArrayHydratorTest extends HydrationTestCase
public function testSimpleMultipleRootEntityQueryWithAliasedArticleEntity() public function testSimpleMultipleRootEntityQueryWithAliasedArticleEntity()
{ {
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsArticle', 'a', 'article'); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsArticle', 'a', 'article');
$rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__id', 'id');
@ -312,6 +314,7 @@ class ArrayHydratorTest extends HydrationTestCase
public function testSimpleMultipleRootEntityQueryWithAliasedEntities() public function testSimpleMultipleRootEntityQueryWithAliasedEntities()
{ {
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', 'user'); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', 'user');
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsArticle', 'a', 'article'); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsArticle', 'a', 'article');
$rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__id', 'id');
@ -369,10 +372,11 @@ class ArrayHydratorTest extends HydrationTestCase
public function testMixedQueryNormalJoin($userEntityKey) public function testMixedQueryNormalJoin($userEntityKey)
{ {
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null);
$rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__id', 'id');
$rsm->addFieldResult('u', 'u__status', 'status'); $rsm->addFieldResult('u', 'u__status', 'status');
$rsm->addScalarResult('sclr0', 'numPhones'); $rsm->addScalarResult('sclr0', 'numPhones', 'integer');
// Faked result set // Faked result set
$resultSet = array( $resultSet = array(
@ -417,6 +421,7 @@ class ArrayHydratorTest extends HydrationTestCase
public function testMixedQueryFetchJoin($userEntityKey) public function testMixedQueryFetchJoin($userEntityKey)
{ {
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null);
$rsm->addJoinedEntityResult( $rsm->addJoinedEntityResult(
'Doctrine\Tests\Models\CMS\CmsPhonenumber', 'Doctrine\Tests\Models\CMS\CmsPhonenumber',
@ -426,7 +431,7 @@ class ArrayHydratorTest extends HydrationTestCase
); );
$rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__id', 'id');
$rsm->addFieldResult('u', 'u__status', 'status'); $rsm->addFieldResult('u', 'u__status', 'status');
$rsm->addScalarResult('sclr0', 'nameUpper'); $rsm->addScalarResult('sclr0', 'nameUpper', 'string');
$rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber');
// Faked result set // Faked result set
@ -487,6 +492,7 @@ class ArrayHydratorTest extends HydrationTestCase
public function testMixedQueryFetchJoinCustomIndex($userEntityKey) public function testMixedQueryFetchJoinCustomIndex($userEntityKey)
{ {
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null);
$rsm->addJoinedEntityResult( $rsm->addJoinedEntityResult(
'Doctrine\Tests\Models\CMS\CmsPhonenumber', 'Doctrine\Tests\Models\CMS\CmsPhonenumber',
@ -496,7 +502,7 @@ class ArrayHydratorTest extends HydrationTestCase
); );
$rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__id', 'id');
$rsm->addFieldResult('u', 'u__status', 'status'); $rsm->addFieldResult('u', 'u__status', 'status');
$rsm->addScalarResult('sclr0', 'nameUpper'); $rsm->addScalarResult('sclr0', 'nameUpper', 'string');
$rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber');
$rsm->addIndexBy('u', 'id'); $rsm->addIndexBy('u', 'id');
$rsm->addIndexBy('p', 'phonenumber'); $rsm->addIndexBy('p', 'phonenumber');
@ -565,6 +571,7 @@ class ArrayHydratorTest extends HydrationTestCase
public function testMixedQueryMultipleFetchJoin() public function testMixedQueryMultipleFetchJoin()
{ {
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
$rsm->addJoinedEntityResult( $rsm->addJoinedEntityResult(
'Doctrine\Tests\Models\CMS\CmsPhonenumber', 'Doctrine\Tests\Models\CMS\CmsPhonenumber',
@ -580,7 +587,7 @@ class ArrayHydratorTest extends HydrationTestCase
); );
$rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__id', 'id');
$rsm->addFieldResult('u', 'u__status', 'status'); $rsm->addFieldResult('u', 'u__status', 'status');
$rsm->addScalarResult('sclr0', 'nameUpper'); $rsm->addScalarResult('sclr0', 'nameUpper', 'string');
$rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber');
$rsm->addFieldResult('a', 'a__id', 'id'); $rsm->addFieldResult('a', 'a__id', 'id');
$rsm->addFieldResult('a', 'a__topic', 'topic'); $rsm->addFieldResult('a', 'a__topic', 'topic');
@ -682,8 +689,8 @@ class ArrayHydratorTest extends HydrationTestCase
*/ */
public function testMixedQueryMultipleDeepMixedFetchJoin() public function testMixedQueryMultipleDeepMixedFetchJoin()
{ {
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
$rsm->addJoinedEntityResult( $rsm->addJoinedEntityResult(
'Doctrine\Tests\Models\CMS\CmsPhonenumber', 'Doctrine\Tests\Models\CMS\CmsPhonenumber',
@ -705,7 +712,7 @@ class ArrayHydratorTest extends HydrationTestCase
); );
$rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__id', 'id');
$rsm->addFieldResult('u', 'u__status', 'status'); $rsm->addFieldResult('u', 'u__status', 'status');
$rsm->addScalarResult('sclr0', 'nameUpper'); $rsm->addScalarResult('sclr0', 'nameUpper', 'string');
$rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber');
$rsm->addFieldResult('a', 'a__id', 'id'); $rsm->addFieldResult('a', 'a__id', 'id');
$rsm->addFieldResult('a', 'a__topic', 'topic'); $rsm->addFieldResult('a', 'a__topic', 'topic');
@ -840,6 +847,7 @@ class ArrayHydratorTest extends HydrationTestCase
public function testEntityQueryCustomResultSetOrder() public function testEntityQueryCustomResultSetOrder()
{ {
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\Forum\ForumCategory', 'c'); $rsm->addEntityResult('Doctrine\Tests\Models\Forum\ForumCategory', 'c');
$rsm->addJoinedEntityResult( $rsm->addJoinedEntityResult(
'Doctrine\Tests\Models\Forum\ForumBoard', 'Doctrine\Tests\Models\Forum\ForumBoard',
@ -915,13 +923,14 @@ class ArrayHydratorTest extends HydrationTestCase
public function testChainedJoinWithScalars($entityKey) public function testChainedJoinWithScalars($entityKey)
{ {
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $entityKey ?: null); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $entityKey ?: null);
$rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__id', 'id');
$rsm->addFieldResult('u', 'u__status', 'status'); $rsm->addFieldResult('u', 'u__status', 'status');
$rsm->addScalarResult('a__id', 'id'); $rsm->addScalarResult('a__id', 'id', 'integer');
$rsm->addScalarResult('a__topic', 'topic'); $rsm->addScalarResult('a__topic', 'topic', 'string');
$rsm->addScalarResult('c__id', 'cid'); $rsm->addScalarResult('c__id', 'cid', 'integer');
$rsm->addScalarResult('c__topic', 'ctopic'); $rsm->addScalarResult('c__topic', 'ctopic', 'string');
// Faked result set // Faked result set
$resultSet = array( $resultSet = array(
@ -984,6 +993,7 @@ class ArrayHydratorTest extends HydrationTestCase
public function testResultIteration() public function testResultIteration()
{ {
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
$rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__id', 'id');
$rsm->addFieldResult('u', 'u__name', 'name'); $rsm->addFieldResult('u', 'u__name', 'name');
@ -1028,6 +1038,7 @@ class ArrayHydratorTest extends HydrationTestCase
public function testResultIterationWithAliasedUserEntity() public function testResultIterationWithAliasedUserEntity()
{ {
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', 'user'); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', 'user');
$rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__id', 'id');
$rsm->addFieldResult('u', 'u__name', 'name'); $rsm->addFieldResult('u', 'u__name', 'name');
@ -1075,6 +1086,7 @@ class ArrayHydratorTest extends HydrationTestCase
public function testSkipUnknownColumns() public function testSkipUnknownColumns()
{ {
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
$rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__id', 'id');
$rsm->addFieldResult('u', 'u__name', 'name'); $rsm->addFieldResult('u', 'u__name', 'name');
@ -1108,10 +1120,11 @@ class ArrayHydratorTest extends HydrationTestCase
public function testMissingIdForRootEntity($userEntityKey) public function testMissingIdForRootEntity($userEntityKey)
{ {
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null);
$rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__id', 'id');
$rsm->addFieldResult('u', 'u__status', 'status'); $rsm->addFieldResult('u', 'u__status', 'status');
$rsm->addScalarResult('sclr0', 'nameUpper'); $rsm->addScalarResult('sclr0', 'nameUpper', 'string');
// Faked result set // Faked result set
$resultSet = array( $resultSet = array(
@ -1166,10 +1179,11 @@ class ArrayHydratorTest extends HydrationTestCase
public function testIndexByAndMixedResult($userEntityKey) public function testIndexByAndMixedResult($userEntityKey)
{ {
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null);
$rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__id', 'id');
$rsm->addFieldResult('u', 'u__status', 'status'); $rsm->addFieldResult('u', 'u__status', 'status');
$rsm->addScalarResult('sclr0', 'nameUpper'); $rsm->addScalarResult('sclr0', 'nameUpper', 'string');
$rsm->addIndexBy('u', 'id'); $rsm->addIndexBy('u', 'id');
// Faked result set // Faked result set

View File

@ -373,7 +373,7 @@ class ObjectHydratorTest extends HydrationTestCase
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null);
$rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__id', 'id');
$rsm->addFieldResult('u', 'u__status', 'status'); $rsm->addFieldResult('u', 'u__status', 'status');
$rsm->addScalarResult('sclr0', 'numPhones'); $rsm->addScalarResult('sclr0', 'numPhones', 'integer');
// Faked result set // Faked result set
$resultSet = array( $resultSet = array(
@ -429,7 +429,7 @@ class ObjectHydratorTest extends HydrationTestCase
$rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__id', 'id');
$rsm->addFieldResult('u', 'u__status', 'status'); $rsm->addFieldResult('u', 'u__status', 'status');
$rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber');
$rsm->addScalarResult('sclr0', 'nameUpper'); $rsm->addScalarResult('sclr0', 'nameUpper', 'string');
// Faked result set // Faked result set
$resultSet = array( $resultSet = array(
@ -506,7 +506,7 @@ class ObjectHydratorTest extends HydrationTestCase
); );
$rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__id', 'id');
$rsm->addFieldResult('u', 'u__status', 'status'); $rsm->addFieldResult('u', 'u__status', 'status');
$rsm->addScalarResult('sclr0', 'nameUpper'); $rsm->addScalarResult('sclr0', 'nameUpper', 'string');
$rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber');
$rsm->addIndexBy('u', 'id'); $rsm->addIndexBy('u', 'id');
$rsm->addIndexBy('p', 'phonenumber'); $rsm->addIndexBy('p', 'phonenumber');
@ -591,7 +591,7 @@ class ObjectHydratorTest extends HydrationTestCase
); );
$rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__id', 'id');
$rsm->addFieldResult('u', 'u__status', 'status'); $rsm->addFieldResult('u', 'u__status', 'status');
$rsm->addScalarResult('sclr0', 'nameUpper'); $rsm->addScalarResult('sclr0', 'nameUpper', 'string');
$rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber');
$rsm->addFieldResult('a', 'a__id', 'id'); $rsm->addFieldResult('a', 'a__id', 'id');
$rsm->addFieldResult('a', 'a__topic', 'topic'); $rsm->addFieldResult('a', 'a__topic', 'topic');
@ -707,7 +707,7 @@ class ObjectHydratorTest extends HydrationTestCase
); );
$rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__id', 'id');
$rsm->addFieldResult('u', 'u__status', 'status'); $rsm->addFieldResult('u', 'u__status', 'status');
$rsm->addScalarResult('sclr0', 'nameUpper'); $rsm->addScalarResult('sclr0', 'nameUpper', 'string');
$rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber');
$rsm->addFieldResult('a', 'a__id', 'id'); $rsm->addFieldResult('a', 'a__id', 'id');
$rsm->addFieldResult('a', 'a__topic', 'topic'); $rsm->addFieldResult('a', 'a__topic', 'topic');
@ -953,8 +953,8 @@ class ObjectHydratorTest extends HydrationTestCase
{ {
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null);
$rsm->addScalarResult('sclr0', 'id'); $rsm->addScalarResult('sclr0', 'id', 'integer');
$rsm->addScalarResult('sclr1', 'name'); $rsm->addScalarResult('sclr1', 'name', 'string');
// Faked result set // Faked result set
$resultSet = array( $resultSet = array(
@ -994,7 +994,7 @@ class ObjectHydratorTest extends HydrationTestCase
$rsm->addEntityResult('Doctrine\Tests\Models\ECommerce\ECommerceProduct', 'p'); $rsm->addEntityResult('Doctrine\Tests\Models\ECommerce\ECommerceProduct', 'p');
$rsm->addFieldResult('p', 'p__id', 'id'); $rsm->addFieldResult('p', 'p__id', 'id');
$rsm->addFieldResult('p', 'p__name', 'name'); $rsm->addFieldResult('p', 'p__name', 'name');
$rsm->addMetaResult('p', 'p__shipping_id', 'shipping_id'); $rsm->addMetaResult('p', 'p__shipping_id', 'shipping_id', false, 'integer');
// Faked result set // Faked result set
$resultSet = array( $resultSet = array(
@ -1039,7 +1039,7 @@ class ObjectHydratorTest extends HydrationTestCase
$rsm->addEntityResult('Doctrine\Tests\Models\ECommerce\ECommerceProduct', 'p', 'product'); $rsm->addEntityResult('Doctrine\Tests\Models\ECommerce\ECommerceProduct', 'p', 'product');
$rsm->addFieldResult('p', 'p__id', 'id'); $rsm->addFieldResult('p', 'p__id', 'id');
$rsm->addFieldResult('p', 'p__name', 'name'); $rsm->addFieldResult('p', 'p__name', 'name');
$rsm->addMetaResult('p', 'p__shipping_id', 'shipping_id'); $rsm->addMetaResult('p', 'p__shipping_id', 'shipping_id', false, 'integer');
// Faked result set // Faked result set
$resultSet = array( $resultSet = array(
@ -1620,7 +1620,7 @@ class ObjectHydratorTest extends HydrationTestCase
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null);
$rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__id', 'id');
$rsm->addFieldResult('u', 'u__status', 'status'); $rsm->addFieldResult('u', 'u__status', 'status');
$rsm->addScalarResult('sclr0', 'nameUpper'); $rsm->addScalarResult('sclr0', 'nameUpper', 'string');
// Faked result set // Faked result set
$resultSet = array( $resultSet = array(
@ -1685,7 +1685,7 @@ class ObjectHydratorTest extends HydrationTestCase
); );
$rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__id', 'id');
$rsm->addFieldResult('u', 'u__status', 'status'); $rsm->addFieldResult('u', 'u__status', 'status');
$rsm->addScalarResult('sclr0', 'nameUpper'); $rsm->addScalarResult('sclr0', 'nameUpper', 'string');
$rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber');
// Faked result set // Faked result set
@ -1747,10 +1747,10 @@ class ObjectHydratorTest extends HydrationTestCase
); );
$rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__id', 'id');
$rsm->addFieldResult('u', 'u__status', 'status'); $rsm->addFieldResult('u', 'u__status', 'status');
$rsm->addScalarResult('sclr0', 'nameUpper'); $rsm->addScalarResult('sclr0', 'nameUpper', 'string');
$rsm->addFieldResult('a', 'a__id', 'id'); $rsm->addFieldResult('a', 'a__id', 'id');
$rsm->addFieldResult('a', 'a__city', 'city'); $rsm->addFieldResult('a', 'a__city', 'city');
$rsm->addMetaResult('a', 'user_id', 'user_id'); $rsm->addMetaResult('a', 'user_id', 'user_id', false, 'string');
// Faked result set // Faked result set
$resultSet = array( $resultSet = array(
@ -1795,7 +1795,7 @@ class ObjectHydratorTest extends HydrationTestCase
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null);
$rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__id', 'id');
$rsm->addFieldResult('u', 'u__status', 'status'); $rsm->addFieldResult('u', 'u__status', 'status');
$rsm->addScalarResult('sclr0', 'nameUpper'); $rsm->addScalarResult('sclr0', 'nameUpper', 'string');
$rsm->addIndexBy('u', 'id'); $rsm->addIndexBy('u', 'id');
// Faked result set // Faked result set
@ -1837,7 +1837,7 @@ class ObjectHydratorTest extends HydrationTestCase
{ {
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null);
$rsm->addScalarResult('sclr0', 'nameUpper'); $rsm->addScalarResult('sclr0', 'nameUpper', 'string');
$rsm->addIndexByScalar('sclr0'); $rsm->addIndexByScalar('sclr0');
// Faked result set // Faked result set
@ -1877,7 +1877,6 @@ class ObjectHydratorTest extends HydrationTestCase
$rsm->addEntityResult('Doctrine\Tests\Models\Company\CompanyFixContract', 'c'); $rsm->addEntityResult('Doctrine\Tests\Models\Company\CompanyFixContract', 'c');
$rsm->addJoinedEntityResult('Doctrine\Tests\Models\Company\CompanyEmployee', 'e', 'c', 'salesPerson'); $rsm->addJoinedEntityResult('Doctrine\Tests\Models\Company\CompanyEmployee', 'e', 'c', 'salesPerson');
$rsm->addFieldResult('c', 'c__id', 'id'); $rsm->addFieldResult('c', 'c__id', 'id');
$rsm->setDiscriminatorColumn('c', 'c_discr'); $rsm->setDiscriminatorColumn('c', 'c_discr');
@ -1905,14 +1904,12 @@ class ObjectHydratorTest extends HydrationTestCase
$rsm->addEntityResult('Doctrine\Tests\Models\Company\CompanyFixContract', 'c'); $rsm->addEntityResult('Doctrine\Tests\Models\Company\CompanyFixContract', 'c');
$rsm->addJoinedEntityResult('Doctrine\Tests\Models\Company\CompanyEmployee', 'e', 'c', 'salesPerson'); $rsm->addJoinedEntityResult('Doctrine\Tests\Models\Company\CompanyEmployee', 'e', 'c', 'salesPerson');
$rsm->addFieldResult('c', 'c__id', 'id'); $rsm->addFieldResult('c', 'c__id', 'id');
$rsm->addMetaResult('c', 'c_discr', 'discr'); $rsm->addMetaResult('c', 'c_discr', 'discr', false, 'string');
$rsm->setDiscriminatorColumn('c', 'c_discr'); $rsm->setDiscriminatorColumn('c', 'c_discr');
$rsm->addFieldResult('e', 'e__id', 'id'); $rsm->addFieldResult('e', 'e__id', 'id');
$rsm->addFieldResult('e', 'e__name', 'name'); $rsm->addFieldResult('e', 'e__name', 'name');
$rsm->addMetaResult('e ', 'e_discr', 'discr'); $rsm->addMetaResult('e ', 'e_discr', 'discr', false, 'string');
$rsm->setDiscriminatorColumn('e', 'e_discr'); $rsm->setDiscriminatorColumn('e', 'e_discr');
$resultSet = array( $resultSet = array(
@ -1940,10 +1937,9 @@ class ObjectHydratorTest extends HydrationTestCase
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\Company\CompanyPerson', 'p'); $rsm->addEntityResult('Doctrine\Tests\Models\Company\CompanyPerson', 'p');
$rsm->addFieldResult('p', 'p__id', 'id'); $rsm->addFieldResult('p', 'p__id', 'id');
$rsm->addFieldResult('p', 'p__name', 'name'); $rsm->addFieldResult('p', 'p__name', 'name');
$rsm->addMetaResult('p', 'discr', 'discr'); $rsm->addMetaResult('p', 'discr', 'discr', false, 'string');
$rsm->setDiscriminatorColumn('p', 'discr'); $rsm->setDiscriminatorColumn('p', 'discr');
$resultSet = array( $resultSet = array(
@ -1968,15 +1964,17 @@ class ObjectHydratorTest extends HydrationTestCase
$rsm->addFieldResult('e1', 'a1__id', 'id'); $rsm->addFieldResult('e1', 'a1__id', 'id');
$rsm->addFieldResult('e2', 'e2__id', 'id'); $rsm->addFieldResult('e2', 'e2__id', 'id');
$result = (new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em)) $resultSet = array(
->hydrateAll( array(
new HydratorMockStatement([[
'a1__id' => '1', 'a1__id' => '1',
'e2__id' => '1', 'e2__id' => '1',
]]), )
$rsm
); );
$stmt = new HydratorMockStatement($resultSet);
$hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em);
$result = $hydrator->hydrateAll($stmt, $rsm);
$this->assertCount(1, $result); $this->assertCount(1, $result);
$this->assertInstanceOf(EntityWithArrayDefaultArrayValueM2M::CLASSNAME, $result[0]); $this->assertInstanceOf(EntityWithArrayDefaultArrayValueM2M::CLASSNAME, $result[0]);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0]->collection); $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0]->collection);

View File

@ -71,17 +71,16 @@ class ResultSetMappingTest extends \Doctrine\Tests\OrmTestCase
{ {
$rms = $this->_rsm; $rms = $this->_rsm;
$rms->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser','u') $this->_rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser','u');
->addJoinedEntityResult('Doctrine\Tests\Models\CMS\CmsPhonenumber','p','u','phonenumbers') $this->_rsm->addJoinedEntityResult('Doctrine\Tests\Models\CMS\CmsPhonenumber','p','u','phonenumbers');
->addFieldResult('u', 'id', 'id') $this->_rsm->addFieldResult('u', 'id', 'id');
->addFieldResult('u', 'name', 'name') $this->_rsm->addFieldResult('u', 'name', 'name');
->setDiscriminatorColumn('name', 'name') $this->_rsm->setDiscriminatorColumn('name', 'name');
->addIndexByColumn('id', 'id') $this->_rsm->addIndexByColumn('id', 'id');
->addIndexBy('username', 'username') $this->_rsm->addIndexBy('username', 'username');
->addIndexByScalar('sclr0') $this->_rsm->addIndexByScalar('sclr0');
->addScalarResult('sclr0', 'numPhones') $this->_rsm->addScalarResult('sclr0', 'numPhones');
->addMetaResult('a', 'user_id', 'user_id'); $this->_rsm->addMetaResult('a', 'user_id', 'user_id');
$this->assertTrue($rms->hasIndexBy('id')); $this->assertTrue($rms->hasIndexBy('id'));
$this->assertTrue($rms->isFieldResult('id')); $this->assertTrue($rms->isFieldResult('id'));
@ -118,6 +117,7 @@ class ResultSetMappingTest extends \Doctrine\Tests\OrmTestCase
'query' => 'SELECT u.id AS user_id, e.id AS email_id, u.name, e.email, u.id + e.id AS scalarColumn FROM cms_users u INNER JOIN cms_emails e ON e.id = u.email_id', 'query' => 'SELECT u.id AS user_id, e.id AS email_id, u.name, e.email, u.id + e.id AS scalarColumn FROM cms_users u INNER JOIN cms_emails e ON e.id = u.email_id',
'resultSetMapping' => 'find-all', 'resultSetMapping' => 'find-all',
)); ));
$cm->addSqlResultSetMapping(array( $cm->addSqlResultSetMapping(array(
'name' => 'find-all', 'name' => 'find-all',
'entities' => array( 'entities' => array(
@ -155,7 +155,6 @@ class ResultSetMappingTest extends \Doctrine\Tests\OrmTestCase
) )
)); ));
$queryMapping = $cm->getNamedNativeQuery('find-all'); $queryMapping = $cm->getNamedNativeQuery('find-all');
$rsm = new \Doctrine\ORM\Query\ResultSetMappingBuilder($this->_em); $rsm = new \Doctrine\ORM\Query\ResultSetMappingBuilder($this->_em);
@ -190,6 +189,7 @@ class ResultSetMappingTest extends \Doctrine\Tests\OrmTestCase
'query' => 'SELECT u.id AS user_id, e.id AS email_id, u.name, e.email, u.id + e.id AS scalarColumn FROM cms_users u INNER JOIN cms_emails e ON e.id = u.email_id', 'query' => 'SELECT u.id AS user_id, e.id AS email_id, u.name, e.email, u.id + e.id AS scalarColumn FROM cms_users u INNER JOIN cms_emails e ON e.id = u.email_id',
'resultSetMapping' => 'find-all', 'resultSetMapping' => 'find-all',
)); ));
$cm->addSqlResultSetMapping(array( $cm->addSqlResultSetMapping(array(
'name' => 'find-all', 'name' => 'find-all',
'entities' => array( 'entities' => array(
@ -204,14 +204,12 @@ class ResultSetMappingTest extends \Doctrine\Tests\OrmTestCase
) )
)); ));
$queryMapping = $cm->getNamedNativeQuery('find-all'); $queryMapping = $cm->getNamedNativeQuery('find-all');
$rsm = new \Doctrine\ORM\Query\ResultSetMappingBuilder($this->_em); $rsm = new \Doctrine\ORM\Query\ResultSetMappingBuilder($this->_em);
$rsm->addNamedNativeQueryMapping($cm, $queryMapping); $rsm->addNamedNativeQueryMapping($cm, $queryMapping);
$this->assertEquals('scalarColumn', $rsm->getScalarAlias('scalarColumn')); $this->assertEquals('scalarColumn', $rsm->getScalarAlias('scalarColumn'));
$this->assertEquals('c0', $rsm->getEntityAlias('id')); $this->assertEquals('c0', $rsm->getEntityAlias('id'));
$this->assertEquals('c0', $rsm->getEntityAlias('name')); $this->assertEquals('c0', $rsm->getEntityAlias('name'));
$this->assertEquals('c0', $rsm->getEntityAlias('status')); $this->assertEquals('c0', $rsm->getEntityAlias('status'));
@ -229,6 +227,7 @@ class ResultSetMappingTest extends \Doctrine\Tests\OrmTestCase
public function testAddNamedNativeQueryResultClass() public function testAddNamedNativeQueryResultClass()
{ {
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
$cm->addNamedNativeQuery(array( $cm->addNamedNativeQuery(array(
@ -238,10 +237,9 @@ class ResultSetMappingTest extends \Doctrine\Tests\OrmTestCase
)); ));
$queryMapping = $cm->getNamedNativeQuery('find-all'); $queryMapping = $cm->getNamedNativeQuery('find-all');
$rsm = new \Doctrine\ORM\Query\ResultSetMappingBuilder($this->_em); $rsm = new \Doctrine\ORM\Query\ResultSetMappingBuilder($this->_em);
$rsm->addNamedNativeQueryMapping($cm, $queryMapping);
$rsm->addNamedNativeQueryMapping($cm, $queryMapping);
$this->assertEquals('c0', $rsm->getEntityAlias('id')); $this->assertEquals('c0', $rsm->getEntityAlias('id'));
$this->assertEquals('c0', $rsm->getEntityAlias('name')); $this->assertEquals('c0', $rsm->getEntityAlias('name'));
@ -259,9 +257,9 @@ class ResultSetMappingTest extends \Doctrine\Tests\OrmTestCase
public function testIndexByMetadataColumn() public function testIndexByMetadataColumn()
{ {
$this->_rsm->addEntityResult('Doctrine\Tests\Models\Legacy\LegacyUser', 'u'); $this->_rsm->addEntityResult('Doctrine\Tests\Models\Legacy\LegacyUser', 'u');
$this->_rsm->addJoinedEntityResult('Doctrine\Tests\Models\Legacy', 'lu', 'u', '_references'); $this->_rsm->addJoinedEntityResult('Doctrine\Tests\Models\LegacyUserReference', 'lu', 'u', '_references');
$this->_rsm->addMetaResult('lu', '_source', '_source', true); $this->_rsm->addMetaResult('lu', '_source', '_source', true, 'integer');
$this->_rsm->addMetaResult('lu', '_target', '_target', true); $this->_rsm->addMetaResult('lu', '_target', '_target', true, 'integer');
$this->_rsm->addIndexBy('lu', '_source'); $this->_rsm->addIndexBy('lu', '_source');
$this->assertTrue($this->_rsm->hasIndexBy('lu')); $this->assertTrue($this->_rsm->hasIndexBy('lu'));

View File

@ -49,9 +49,9 @@ class ScalarHydratorTest extends HydrationTestCase
public function testHydrateScalarResults() public function testHydrateScalarResults()
{ {
$rsm = new ResultSetMapping(); $rsm = new ResultSetMapping();
$rsm->addScalarResult('foo1', 'foo'); $rsm->addScalarResult('foo1', 'foo', 'string');
$rsm->addScalarResult('bar2', 'bar'); $rsm->addScalarResult('bar2', 'bar', 'string');
$rsm->addScalarResult('baz3', 'baz'); $rsm->addScalarResult('baz3', 'baz', 'string');
$resultSet = array( $resultSet = array(
array( array(
@ -76,9 +76,9 @@ class ScalarHydratorTest extends HydrationTestCase
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u');
$rsm->addFieldResult('u', 'u__id', 'id'); $rsm->addFieldResult('u', 'u__id', 'id');
$rsm->addFieldResult('u', 'u__name', 'name'); $rsm->addFieldResult('u', 'u__name', 'name');
$rsm->addScalarResult('foo1', 'foo'); $rsm->addScalarResult('foo1', 'foo', 'string');
$rsm->addScalarResult('bar2', 'bar'); $rsm->addScalarResult('bar2', 'bar', 'string');
$rsm->addScalarResult('baz3', 'baz'); $rsm->addScalarResult('baz3', 'baz', 'string');
$resultSet = array( $resultSet = array(
array( array(

View File

@ -19,7 +19,7 @@ class SimpleObjectHydratorTest extends HydrationTestCase
$rsm->addEntityResult('Doctrine\Tests\Models\Company\CompanyPerson', 'p'); $rsm->addEntityResult('Doctrine\Tests\Models\Company\CompanyPerson', 'p');
$rsm->addFieldResult('p', 'p__id', 'id'); $rsm->addFieldResult('p', 'p__id', 'id');
$rsm->addFieldResult('p', 'p__name', 'name'); $rsm->addFieldResult('p', 'p__name', 'name');
$rsm->addMetaResult('p ', 'discr', 'discr'); $rsm->addMetaResult('p ', 'discr', 'discr', false, 'string');
$rsm->setDiscriminatorColumn('p', 'discr'); $rsm->setDiscriminatorColumn('p', 'discr');
$resultSet = array( $resultSet = array(
array( array(
@ -71,7 +71,7 @@ class SimpleObjectHydratorTest extends HydrationTestCase
$rsm->addFieldResult('p', 'p__id', 'id'); $rsm->addFieldResult('p', 'p__id', 'id');
$rsm->addFieldResult('p', 'p__name', 'name'); $rsm->addFieldResult('p', 'p__name', 'name');
$rsm->addMetaResult('p', 'discr', 'discr'); $rsm->addMetaResult('p', 'discr', 'discr', false, 'string');
$rsm->setDiscriminatorColumn('p', 'discr'); $rsm->setDiscriminatorColumn('p', 'discr');
$resultSet = array( $resultSet = array(

View File

@ -491,8 +491,8 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
$class = $factory->getMetadataFor('Doctrine\Tests\Models\DDC1476\DDC1476EntityWithDefaultFieldType'); $class = $factory->getMetadataFor('Doctrine\Tests\Models\DDC1476\DDC1476EntityWithDefaultFieldType');
$this->assertEquals('ID', $class->columnNames['id']); $this->assertEquals('ID', $class->getColumnName('id'));
$this->assertEquals('NAME', $class->columnNames['name']); $this->assertEquals('NAME', $class->getColumnName('name'));
$this->assertEquals('DDC1476ENTITY_WITH_DEFAULT_FIELD_TYPE', $class->table['name']); $this->assertEquals('DDC1476ENTITY_WITH_DEFAULT_FIELD_TYPE', $class->table['name']);
} }

View File

@ -254,7 +254,7 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase
$cm1->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); $cm1->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
$cm1->setPrimaryTable(array('name' => '`group`')); $cm1->setPrimaryTable(array('name' => '`group`'));
// Add a mapped field // Add a mapped field
$cm1->mapField(array('fieldName' => 'name', 'type' => 'varchar')); $cm1->mapField(array('fieldName' => 'name', 'type' => 'string'));
// Add a mapped field // Add a mapped field
$cm1->mapField(array('fieldName' => 'id', 'type' => 'integer', 'id' => true)); $cm1->mapField(array('fieldName' => 'id', 'type' => 'integer', 'id' => true));
// and a mapped association // and a mapped association

View File

@ -1,7 +1,5 @@
<?php <?php
use Doctrine\ORM\Mapping\ClassMetadataInfo;
$metadata->setPrimaryTable(array( $metadata->setPrimaryTable(array(
'name' => 'company_person', 'name' => 'company_person',
)); ));

View File

@ -1,7 +1,5 @@
<?php <?php
use Doctrine\ORM\Mapping\ClassMetadataInfo;
$metadata->setPrimaryTable(array( $metadata->setPrimaryTable(array(
'name' => 'cms_users', 'name' => 'cms_users',
)); ));

View File

@ -2,7 +2,7 @@
use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\ORM\Mapping\ClassMetadataInfo;
$metadata->setInheritanceType(\Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_JOINED); $metadata->setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_JOINED);
$metadata->setTableName( 'company_contracts'); $metadata->setTableName( 'company_contracts');
$metadata->setDiscriminatorColumn(array( $metadata->setDiscriminatorColumn(array(
'name' => 'discr', 'name' => 'discr',

View File

@ -1,7 +1,5 @@
<?php <?php
use Doctrine\ORM\Mapping\ClassMetadataInfo;
$metadata->setPrimaryTable(array( $metadata->setPrimaryTable(array(
'name' => 'company_person', 'name' => 'company_person',
)); ));

View File

@ -9,6 +9,7 @@ use Doctrine\Tests\Mocks\ConnectionMock;
use Doctrine\Tests\Mocks\DriverMock; use Doctrine\Tests\Mocks\DriverMock;
use Doctrine\Tests\Mocks\EntityManagerMock; use Doctrine\Tests\Mocks\EntityManagerMock;
use Doctrine\Tests\Models\ECommerce\ECommerceCart; use Doctrine\Tests\Models\ECommerce\ECommerceCart;
use Doctrine\Tests\Models\ECommerce\ECommerceProduct;
use Doctrine\Tests\OrmTestCase; use Doctrine\Tests\OrmTestCase;
/** /**
@ -83,4 +84,28 @@ class PersistentCollectionTest extends OrmTestCase
$this->collection->next(); $this->collection->next();
$this->assertTrue($this->collection->isInitialized()); $this->assertTrue($this->collection->isInitialized());
} }
/**
* @group DDC-3382
*/
public function testNonObjects()
{
$this->setUpPersistentCollection();
$this->assertEmpty($this->collection);
$this->collection->add("dummy");
$this->assertNotEmpty($this->collection);
$product = new ECommerceProduct();
$this->collection->set(1, $product);
$this->collection->set(2, "dummy");
$this->collection->set(3, null);
$this->assertSame($product, $this->collection->get(1));
$this->assertSame("dummy", $this->collection->get(2));
$this->assertSame(null, $this->collection->get(3));
}
} }

View File

@ -92,7 +92,7 @@ class BasicEntityPersisterTypeValueSqlTest extends \Doctrine\Tests\OrmTestCase
*/ */
public function testStripNonAlphanumericCharactersFromSelectColumnListSQL() public function testStripNonAlphanumericCharactersFromSelectColumnListSQL()
{ {
$persister = new BasicEntityPersister($this->_em, $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Ticket\DDC1719SimpleEntity')); $persister = new BasicEntityPersister($this->_em, $this->_em->getClassMetadata('Doctrine\Tests\Models\Generic\NonAlphaColumnsEntity'));
$method = new \ReflectionMethod($persister, 'getSelectColumnsSQL'); $method = new \ReflectionMethod($persister, 'getSelectColumnsSQL');
$method->setAccessible(true); $method->setAccessible(true);
@ -143,16 +143,16 @@ class BasicEntityPersisterTypeValueSqlTest extends \Doctrine\Tests\OrmTestCase
public function testCountCondition() public function testCountCondition()
{ {
$persister = new BasicEntityPersister($this->_em, $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Ticket\DDC1719SimpleEntity')); $persister = new BasicEntityPersister($this->_em, $this->_em->getClassMetadata('Doctrine\Tests\Models\Generic\NonAlphaColumnsEntity'));
// Using a criteria as array // Using a criteria as array
$statement = $persister->getCountSQL(array('value' => 'bar')); $statement = $persister->getCountSQL(array('value' => 'bar'));
$this->assertEquals('SELECT COUNT(*) FROM "ddc-1719-simple-entity" t0 WHERE t0."simple-entity-value" = ?', $statement); $this->assertEquals('SELECT COUNT(*) FROM "not-a-simple-entity" t0 WHERE t0."simple-entity-value" = ?', $statement);
// Using a criteria object // Using a criteria object
$criteria = new Criteria(Criteria::expr()->eq('value', 'bar')); $criteria = new Criteria(Criteria::expr()->eq('value', 'bar'));
$statement = $persister->getCountSQL($criteria); $statement = $persister->getCountSQL($criteria);
$this->assertEquals('SELECT COUNT(*) FROM "ddc-1719-simple-entity" t0 WHERE t0."simple-entity-value" = ?', $statement); $this->assertEquals('SELECT COUNT(*) FROM "not-a-simple-entity" t0 WHERE t0."simple-entity-value" = ?', $statement);
} }
public function testCountEntities() public function testCountEntities()

View File

@ -1889,18 +1889,18 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
public function testStripNonAlphanumericCharactersFromAlias() public function testStripNonAlphanumericCharactersFromAlias()
{ {
$this->assertSqlGeneration( $this->assertSqlGeneration(
'SELECT e FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1719SimpleEntity e', 'SELECT e FROM Doctrine\Tests\Models\Generic\NonAlphaColumnsEntity e',
'SELECT d0_."simple-entity-id" AS simpleentityid_0, d0_."simple-entity-value" AS simpleentityvalue_1 FROM "ddc-1719-simple-entity" d0_' 'SELECT n0_."simple-entity-id" AS simpleentityid_0, n0_."simple-entity-value" AS simpleentityvalue_1 FROM "not-a-simple-entity" n0_'
); );
$this->assertSqlGeneration( $this->assertSqlGeneration(
'SELECT e.value FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1719SimpleEntity e ORDER BY e.value', 'SELECT e.value FROM Doctrine\Tests\Models\Generic\NonAlphaColumnsEntity e ORDER BY e.value',
'SELECT d0_."simple-entity-value" AS simpleentityvalue_0 FROM "ddc-1719-simple-entity" d0_ ORDER BY d0_."simple-entity-value" ASC' 'SELECT n0_."simple-entity-value" AS simpleentityvalue_0 FROM "not-a-simple-entity" n0_ ORDER BY n0_."simple-entity-value" ASC'
); );
$this->assertSqlGeneration( $this->assertSqlGeneration(
'SELECT TRIM(e.value) FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1719SimpleEntity e ORDER BY e.value', 'SELECT TRIM(e.value) FROM Doctrine\Tests\Models\Generic\NonAlphaColumnsEntity e ORDER BY e.value',
'SELECT TRIM(d0_."simple-entity-value") AS sclr_0 FROM "ddc-1719-simple-entity" d0_ ORDER BY d0_."simple-entity-value" ASC' 'SELECT TRIM(n0_."simple-entity-value") AS sclr_0 FROM "not-a-simple-entity" n0_ ORDER BY n0_."simple-entity-value" ASC'
); );
} }

View File

@ -4,7 +4,6 @@ namespace Doctrine\Tests\ORM\Tools;
use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Persistence\Mapping\RuntimeReflectionService; use Doctrine\Common\Persistence\Mapping\RuntimeReflectionService;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Mapping\ClassMetadataFactory; use Doctrine\ORM\Mapping\ClassMetadataFactory;
use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\ORM\Mapping\ClassMetadataInfo;
use Doctrine\ORM\Mapping\Driver\AnnotationDriver; use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
@ -408,7 +407,7 @@ class EntityGeneratorTest extends OrmTestCase
$reflectionService = new RuntimeReflectionService(); $reflectionService = new RuntimeReflectionService();
$cm = new ClassMetadata($metadata->name); $cm = new ClassMetadataInfo($metadata->name);
$cm->initializeReflection($reflectionService); $cm->initializeReflection($reflectionService);
$driver = $this->createAnnotationDriver(); $driver = $this->createAnnotationDriver();
@ -427,7 +426,7 @@ class EntityGeneratorTest extends OrmTestCase
$isbn = $this->newInstance($embeddedMetadata); $isbn = $this->newInstance($embeddedMetadata);
$cm = new ClassMetadata($embeddedMetadata->name); $cm = new ClassMetadataInfo($embeddedMetadata->name);
$cm->initializeReflection($reflectionService); $cm->initializeReflection($reflectionService);
$driver->loadMetadataForClass($cm->name, $cm); $driver->loadMetadataForClass($cm->name, $cm);
@ -450,7 +449,7 @@ class EntityGeneratorTest extends OrmTestCase
$reflectionService = new RuntimeReflectionService(); $reflectionService = new RuntimeReflectionService();
$cm = new ClassMetadata($metadata->name); $cm = new ClassMetadataInfo($metadata->name);
$cm->initializeReflection($reflectionService); $cm->initializeReflection($reflectionService);
$driver->loadMetadataForClass($cm->name, $cm); $driver->loadMetadataForClass($cm->name, $cm);
@ -464,7 +463,7 @@ class EntityGeneratorTest extends OrmTestCase
$isbn = $this->newInstance($embeddedMetadata); $isbn = $this->newInstance($embeddedMetadata);
$cm = new ClassMetadata($embeddedMetadata->name); $cm = new ClassMetadataInfo($embeddedMetadata->name);
$cm->initializeReflection($reflectionService); $cm->initializeReflection($reflectionService);
$driver->loadMetadataForClass($cm->name, $cm); $driver->loadMetadataForClass($cm->name, $cm);
@ -488,7 +487,7 @@ class EntityGeneratorTest extends OrmTestCase
$this->newInstance($metadata); // force instantiation (causes autoloading to kick in) $this->newInstance($metadata); // force instantiation (causes autoloading to kick in)
$driver = new AnnotationDriver(new AnnotationReader(), array()); $driver = new AnnotationDriver(new AnnotationReader(), array());
$cm = new ClassMetadata($metadata->name); $cm = new ClassMetadataInfo($metadata->name);
$cm->initializeReflection(new RuntimeReflectionService); $cm->initializeReflection(new RuntimeReflectionService);
$driver->loadMetadataForClass($cm->name, $cm); $driver->loadMetadataForClass($cm->name, $cm);
@ -593,7 +592,7 @@ class EntityGeneratorTest extends OrmTestCase
*/ */
public function testGetInheritanceTypeString() public function testGetInheritanceTypeString()
{ {
$reflection = new \ReflectionClass('\Doctrine\ORM\Mapping\ClassMetadata'); $reflection = new \ReflectionClass('\Doctrine\ORM\Mapping\ClassMetadataInfo');
$method = new \ReflectionMethod($this->_generator, 'getInheritanceTypeString'); $method = new \ReflectionMethod($this->_generator, 'getInheritanceTypeString');
$constants = $reflection->getConstants(); $constants = $reflection->getConstants();
$pattern = '/^INHERITANCE_TYPE_/'; $pattern = '/^INHERITANCE_TYPE_/';
@ -647,7 +646,7 @@ class EntityGeneratorTest extends OrmTestCase
*/ */
public function testGetIdGeneratorTypeString() public function testGetIdGeneratorTypeString()
{ {
$reflection = new \ReflectionClass('\Doctrine\ORM\Mapping\ClassMetadata'); $reflection = new \ReflectionClass('\Doctrine\ORM\Mapping\ClassMetadataInfo');
$method = new \ReflectionMethod($this->_generator, 'getIdGeneratorTypeString'); $method = new \ReflectionMethod($this->_generator, 'getIdGeneratorTypeString');
$constants = $reflection->getConstants(); $constants = $reflection->getConstants();
$pattern = '/^GENERATOR_TYPE_/'; $pattern = '/^GENERATOR_TYPE_/';

View File

@ -71,25 +71,25 @@ abstract class AbstractClassMetadataExporterTest extends \Doctrine\Tests\OrmTest
'xml' => 'Doctrine\ORM\Mapping\Driver\XmlDriver', 'xml' => 'Doctrine\ORM\Mapping\Driver\XmlDriver',
'yaml' => 'Doctrine\ORM\Mapping\Driver\YamlDriver', 'yaml' => 'Doctrine\ORM\Mapping\Driver\YamlDriver',
); );
$this->assertArrayHasKey($type, $mappingDriver, "There is no metadata driver for the type '" . $type . "'.");
$class = $mappingDriver[$type];
if ($type === 'annotation') { $this->assertArrayHasKey($type, $mappingDriver, "There is no metadata driver for the type '" . $type . "'.");
$driver = $this->createAnnotationDriver(array($path));
} else { $class = $mappingDriver[$type];
$driver = new $class($path); $driver = ($type === 'annotation')
} ? $this->createAnnotationDriver(array($path))
: new $class($path);
return $driver; return $driver;
} }
protected function _createClassMetadataFactory($em, $type) protected function _createClassMetadataFactory($em, $type)
{ {
if ($type === 'annotation') { $factory = ($type === 'annotation')
$factory = new ClassMetadataFactory(); ? new ClassMetadataFactory()
} else { : new DisconnectedClassMetadataFactory();
$factory = new DisconnectedClassMetadataFactory();
}
$factory->setEntityManager($em); $factory->setEntityManager($em);
return $factory; return $factory;
} }
@ -110,11 +110,14 @@ abstract class AbstractClassMetadataExporterTest extends \Doctrine\Tests\OrmTest
$type = $this->_getType(); $type = $this->_getType();
$cme = new ClassMetadataExporter(); $cme = new ClassMetadataExporter();
$exporter = $cme->getExporter($type, __DIR__ . '/export/' . $type); $exporter = $cme->getExporter($type, __DIR__ . '/export/' . $type);
if ($type === 'annotation') { if ($type === 'annotation') {
$entityGenerator = new EntityGenerator(); $entityGenerator = new EntityGenerator();
$entityGenerator->setAnnotationPrefix(""); $entityGenerator->setAnnotationPrefix("");
$exporter->setEntityGenerator($entityGenerator); $exporter->setEntityGenerator($entityGenerator);
} }
$this->_extension = $exporter->getExtension(); $this->_extension = $exporter->getExtension();
$exporter->setMetadata($metadata); $exporter->setMetadata($metadata);
@ -215,6 +218,7 @@ abstract class AbstractClassMetadataExporterTest extends \Doctrine\Tests\OrmTest
public function testFieldsAreProperlySerialized() public function testFieldsAreProperlySerialized()
{ {
$type = $this->_getType(); $type = $this->_getType();
if ($type == 'xml') { if ($type == 'xml') {
$xml = simplexml_load_file(__DIR__ . '/export/'.$type.'/Doctrine.Tests.ORM.Tools.Export.ExportedUser.dcm.xml'); $xml = simplexml_load_file(__DIR__ . '/export/'.$type.'/Doctrine.Tests.ORM.Tools.Export.ExportedUser.dcm.xml');
@ -224,8 +228,7 @@ abstract class AbstractClassMetadataExporterTest extends \Doctrine\Tests\OrmTest
$nodes = $xml->xpath("/d:doctrine-mapping/d:entity/d:field[@name='name' and @type='string' and @unique='true']"); $nodes = $xml->xpath("/d:doctrine-mapping/d:entity/d:field[@name='name' and @type='string' and @unique='true']");
$this->assertEquals(1, count($nodes)); $this->assertEquals(1, count($nodes));
} } else {
else {
$this->markTestSkipped('Test not available for '.$type.' driver'); $this->markTestSkipped('Test not available for '.$type.' driver');
} }
} }
@ -361,6 +364,7 @@ abstract class AbstractClassMetadataExporterTest extends \Doctrine\Tests\OrmTest
public function testCascadeAllCollapsed() public function testCascadeAllCollapsed()
{ {
$type = $this->_getType(); $type = $this->_getType();
if ($type == 'xml') { if ($type == 'xml') {
$xml = simplexml_load_file(__DIR__ . '/export/'.$type.'/Doctrine.Tests.ORM.Tools.Export.ExportedUser.dcm.xml'); $xml = simplexml_load_file(__DIR__ . '/export/'.$type.'/Doctrine.Tests.ORM.Tools.Export.ExportedUser.dcm.xml');
@ -369,19 +373,18 @@ abstract class AbstractClassMetadataExporterTest extends \Doctrine\Tests\OrmTest
$this->assertEquals(1, count($nodes)); $this->assertEquals(1, count($nodes));
$this->assertEquals('cascade-all', $nodes[0]->getName()); $this->assertEquals('cascade-all', $nodes[0]->getName());
} elseif ($type == 'yaml') { } else if ($type == 'yaml') {
$yaml = new \Symfony\Component\Yaml\Parser(); $yaml = new \Symfony\Component\Yaml\Parser();
$value = $yaml->parse(file_get_contents(__DIR__ . '/export/'.$type.'/Doctrine.Tests.ORM.Tools.Export.ExportedUser.dcm.yml')); $value = $yaml->parse(file_get_contents(__DIR__ . '/export/'.$type.'/Doctrine.Tests.ORM.Tools.Export.ExportedUser.dcm.yml'));
$this->assertTrue(isset($value['Doctrine\Tests\ORM\Tools\Export\ExportedUser']['oneToMany']['interests']['cascade'])); $this->assertTrue(isset($value['Doctrine\Tests\ORM\Tools\Export\ExportedUser']['oneToMany']['interests']['cascade']));
$this->assertEquals(1, count($value['Doctrine\Tests\ORM\Tools\Export\ExportedUser']['oneToMany']['interests']['cascade'])); $this->assertEquals(1, count($value['Doctrine\Tests\ORM\Tools\Export\ExportedUser']['oneToMany']['interests']['cascade']));
$this->assertEquals('all', $value['Doctrine\Tests\ORM\Tools\Export\ExportedUser']['oneToMany']['interests']['cascade'][0]); $this->assertEquals('all', $value['Doctrine\Tests\ORM\Tools\Export\ExportedUser']['oneToMany']['interests']['cascade'][0]);
} else { } else {
$this->markTestSkipped('Test not available for '.$type.' driver'); $this->markTestSkipped('Test not available for '.$type.' driver');
} }
} }
public function __destruct() public function __destruct()
{ {
# $this->_deleteDirectory(__DIR__ . '/export/'.$this->_getType()); # $this->_deleteDirectory(__DIR__ . '/export/'.$this->_getType());
@ -393,11 +396,13 @@ abstract class AbstractClassMetadataExporterTest extends \Doctrine\Tests\OrmTest
return unlink($path); return unlink($path);
} else if (is_dir($path)) { } else if (is_dir($path)) {
$files = glob(rtrim($path,'/').'/*'); $files = glob(rtrim($path,'/').'/*');
if (is_array($files)) { if (is_array($files)) {
foreach ($files as $file){ foreach ($files as $file){
$this->_deleteDirectory($file); $this->_deleteDirectory($file);
} }
} }
return rmdir($path); return rmdir($path);
} }
} }

View File

@ -300,6 +300,12 @@ abstract class OrmFunctionalTestCase extends OrmTestCase
protected function tearDown() protected function tearDown()
{ {
$conn = static::$_sharedConn; $conn = static::$_sharedConn;
// In case test is skipped, tearDown is called, but no setup may have run
if ( ! $conn) {
return;
}
$platform = $conn->getDatabasePlatform(); $platform = $conn->getDatabasePlatform();
$this->_sqlLoggerStack->enabled = false; $this->_sqlLoggerStack->enabled = false;

View File

@ -2,7 +2,9 @@
namespace Doctrine\Tests; namespace Doctrine\Tests;
use Doctrine\Common\Annotations;
use Doctrine\Common\Cache\ArrayCache; use Doctrine\Common\Cache\ArrayCache;
use Doctrine\Common\Version;
use Doctrine\ORM\Cache\DefaultCacheFactory; use Doctrine\ORM\Cache\DefaultCacheFactory;
/** /**
@ -57,40 +59,41 @@ abstract class OrmTestCase extends DoctrineTestCase
*/ */
protected function createAnnotationDriver($paths = array(), $alias = null) protected function createAnnotationDriver($paths = array(), $alias = null)
{ {
if (version_compare(\Doctrine\Common\Version::VERSION, '3.0.0', '>=')) { if (version_compare(Version::VERSION, '3.0.0', '>=')) {
$reader = new \Doctrine\Common\Annotations\CachedReader( $reader = new Annotations\CachedReader(new Annotations\AnnotationReader(), new ArrayCache());
new \Doctrine\Common\Annotations\AnnotationReader(), new ArrayCache() } else if (version_compare(Version::VERSION, '2.2.0-DEV', '>=')) {
);
}
else if (version_compare(\Doctrine\Common\Version::VERSION, '2.2.0-DEV', '>=')) {
// Register the ORM Annotations in the AnnotationRegistry // Register the ORM Annotations in the AnnotationRegistry
$reader = new \Doctrine\Common\Annotations\SimpleAnnotationReader(); $reader = new Annotations\SimpleAnnotationReader();
$reader->addNamespace('Doctrine\ORM\Mapping'); $reader->addNamespace('Doctrine\ORM\Mapping');
$reader = new \Doctrine\Common\Annotations\CachedReader($reader, new ArrayCache());
} $reader = new Annotations\CachedReader($reader, new ArrayCache());
else if (version_compare(\Doctrine\Common\Version::VERSION, '2.1.0-BETA3-DEV', '>=')) { } else if (version_compare(Version::VERSION, '2.1.0-BETA3-DEV', '>=')) {
$reader = new \Doctrine\Common\Annotations\AnnotationReader(); $reader = new Annotations\AnnotationReader();
$reader->setIgnoreNotImportedAnnotations(true); $reader->setIgnoreNotImportedAnnotations(true);
$reader->setEnableParsePhpImports(false); $reader->setEnableParsePhpImports(false);
if ($alias) { if ($alias) {
$reader->setAnnotationNamespaceAlias('Doctrine\ORM\Mapping\\', $alias); $reader->setAnnotationNamespaceAlias('Doctrine\ORM\Mapping\\', $alias);
} else { } else {
$reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\'); $reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\');
} }
$reader = new \Doctrine\Common\Annotations\CachedReader(
new \Doctrine\Common\Annotations\IndexedReader($reader), new ArrayCache() $reader = new Annotations\CachedReader(new Annotations\IndexedReader($reader), new ArrayCache());
);
} else { } else {
$reader = new \Doctrine\Common\Annotations\AnnotationReader(); $reader = new Annotations\AnnotationReader();
if ($alias) { if ($alias) {
$reader->setAnnotationNamespaceAlias('Doctrine\ORM\Mapping\\', $alias); $reader->setAnnotationNamespaceAlias('Doctrine\ORM\Mapping\\', $alias);
} else { } else {
$reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\'); $reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\');
} }
} }
\Doctrine\Common\Annotations\AnnotationRegistry::registerFile(
__DIR__ . "/../../../lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php"); Annotations\AnnotationRegistry::registerFile(__DIR__ . "/../../../lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php");
return new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, (array)$paths);
return new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, (array) $paths);
} }
/** /**
@ -112,7 +115,7 @@ abstract class OrmTestCase extends DoctrineTestCase
{ {
$metadataCache = $withSharedMetadata $metadataCache = $withSharedMetadata
? self::getSharedMetadataCacheImpl() ? self::getSharedMetadataCacheImpl()
: new \Doctrine\Common\Cache\ArrayCache; : new ArrayCache();
$config = new \Doctrine\ORM\Configuration(); $config = new \Doctrine\ORM\Configuration();
@ -166,7 +169,7 @@ abstract class OrmTestCase extends DoctrineTestCase
private static function getSharedMetadataCacheImpl() private static function getSharedMetadataCacheImpl()
{ {
if (self::$_metadataCacheImpl === null) { if (self::$_metadataCacheImpl === null) {
self::$_metadataCacheImpl = new \Doctrine\Common\Cache\ArrayCache; self::$_metadataCacheImpl = new ArrayCache();
} }
return self::$_metadataCacheImpl; return self::$_metadataCacheImpl;
@ -178,7 +181,7 @@ abstract class OrmTestCase extends DoctrineTestCase
private static function getSharedQueryCacheImpl() private static function getSharedQueryCacheImpl()
{ {
if (self::$_queryCacheImpl === null) { if (self::$_queryCacheImpl === null) {
self::$_queryCacheImpl = new \Doctrine\Common\Cache\ArrayCache; self::$_queryCacheImpl = new ArrayCache();
} }
return self::$_queryCacheImpl; return self::$_queryCacheImpl;
@ -190,7 +193,7 @@ abstract class OrmTestCase extends DoctrineTestCase
protected function getSharedSecondLevelCacheDriverImpl() protected function getSharedSecondLevelCacheDriverImpl()
{ {
if ($this->secondLevelCacheDriverImpl === null) { if ($this->secondLevelCacheDriverImpl === null) {
$this->secondLevelCacheDriverImpl = new \Doctrine\Common\Cache\ArrayCache(); $this->secondLevelCacheDriverImpl = new ArrayCache();
} }
return $this->secondLevelCacheDriverImpl; return $this->secondLevelCacheDriverImpl;