mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 15:02:22 +01:00
Compare commits
75 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
173b398b34 | ||
|
|
de22e726a4 | ||
|
|
dab2b505a4 | ||
|
|
0672688088 | ||
|
|
660f89f745 | ||
|
|
e0aa01ddb6 | ||
|
|
287b29aeaa | ||
|
|
86132283f1 | ||
|
|
f75c3b517d | ||
|
|
6e7e4dd35a | ||
|
|
faedbfc09a | ||
|
|
45269fe4f2 | ||
|
|
a3fea32e0e | ||
|
|
c90ed73b33 | ||
|
|
83943e86a2 | ||
|
|
1aab5feb4a | ||
|
|
469bd02b41 | ||
|
|
24f74bc935 | ||
|
|
77d060ab74 | ||
|
|
01148e52f3 | ||
|
|
5756021571 | ||
|
|
006d3833f6 | ||
|
|
8865a5b90d | ||
|
|
d0698754b2 | ||
|
|
4ea7a5dde4 | ||
|
|
ed11e61812 | ||
|
|
e7e69daabe | ||
|
|
c6eb04de14 | ||
|
|
8c2009c67e | ||
|
|
a7ed9e638b | ||
|
|
643ed0b8f5 | ||
|
|
57db88b62a | ||
|
|
3c944b34ca | ||
|
|
1618a3e393 | ||
|
|
a1094d352c | ||
|
|
e4ef9e03ae | ||
|
|
a3c98b1087 | ||
|
|
2ce877bf8a | ||
|
|
6d35fad70f | ||
|
|
612ed2b3a2 | ||
|
|
95a85d67ea | ||
|
|
edaab11a86 | ||
|
|
1627c974b9 | ||
|
|
c6118cb045 | ||
|
|
461d201e40 | ||
|
|
653aef2c83 | ||
|
|
045d058cec | ||
|
|
9dbf4d8480 | ||
|
|
2229a5e4c6 | ||
|
|
bbf092c6fd | ||
|
|
6fee945fda | ||
|
|
974f18da0c | ||
|
|
9b198be070 | ||
|
|
b610855248 | ||
|
|
994917aa23 | ||
|
|
d64be2888e | ||
|
|
737e47e155 | ||
|
|
ef4ff8be81 | ||
|
|
b53c81ae8d | ||
|
|
6bad010959 | ||
|
|
26cfbdd08b | ||
|
|
e8412b85df | ||
|
|
2e5d7416d8 | ||
|
|
1988944e7e | ||
|
|
564ec1ee2a | ||
|
|
cb0cddef83 | ||
|
|
8b2c92a6bd | ||
|
|
825a68bcba | ||
|
|
abd11374ee | ||
|
|
518357d987 | ||
|
|
4109f22000 | ||
|
|
c60e6523e9 | ||
|
|
04262e2b73 | ||
|
|
084101e287 | ||
|
|
ea2b288578 |
@@ -1,5 +1,13 @@
|
||||
# Upgrade to 2.3
|
||||
|
||||
## EntityManager#find() not calls EntityRepository#find() anymore
|
||||
|
||||
Previous to 2.3, calling ``EntityManager#find()`` would be delegated to
|
||||
``EntityRepository#find()``. This has lead to some unexpected behavior in the
|
||||
core of Doctrine when people have overwritten the find method in their
|
||||
repositories. That is why this behavior has been reversed in 2.3, and
|
||||
``EntityRepository#find()`` calls ``EntityManager#find()`` instead.
|
||||
|
||||
## EntityGenerator add*() method generation
|
||||
|
||||
When generating an add*() method for a collection the EntityGenerator will now not
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "doctrine/orm",
|
||||
"type": "library","version":"2.3.0",
|
||||
"type": "library","version":"2.3.1",
|
||||
"description": "Object-Relational-Mapper for PHP",
|
||||
"keywords": ["orm", "database"],
|
||||
"homepage": "http://www.doctrine-project.org",
|
||||
|
||||
@@ -281,7 +281,7 @@ abstract class AbstractQuery
|
||||
|
||||
$value = $values[$class->getSingleIdentifierFieldName()];
|
||||
|
||||
if ( ! $value) {
|
||||
if (null === $value) {
|
||||
throw new \InvalidArgumentException(
|
||||
"Binding entities to query parameters only allowed for entities that have an identifier."
|
||||
);
|
||||
|
||||
@@ -161,13 +161,14 @@ class EntityRepository implements ObjectRepository, Selectable
|
||||
* Finds a single entity by a set of criteria.
|
||||
*
|
||||
* @param array $criteria
|
||||
* @param array|null $orderBy
|
||||
* @return object
|
||||
*/
|
||||
public function findOneBy(array $criteria)
|
||||
public function findOneBy(array $criteria, array $orderBy = null)
|
||||
{
|
||||
$persister = $this->_em->getUnitOfWork()->getEntityPersister($this->_entityName);
|
||||
|
||||
return $persister->load($criteria, null, null, array(), 0, 1);
|
||||
return $persister->load($criteria, null, null, array(), 0, 1, $orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -215,7 +216,7 @@ class EntityRepository implements ObjectRepository, Selectable
|
||||
case 3:
|
||||
return $this->$method(array($fieldName => $arguments[0]), $arguments[1], $arguments[2]);
|
||||
|
||||
case 4;
|
||||
case 4:
|
||||
return $this->$method(array($fieldName => $arguments[0]), $arguments[1], $arguments[2], $arguments[3]);
|
||||
|
||||
default:
|
||||
|
||||
@@ -1478,6 +1478,8 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
'onDelete' => 'CASCADE'));
|
||||
}
|
||||
|
||||
$mapping['joinTableColumns'] = array();
|
||||
|
||||
foreach ($mapping['joinTable']['joinColumns'] as &$joinColumn) {
|
||||
if (empty($joinColumn['name'])) {
|
||||
$joinColumn['name'] = $this->namingStrategy->joinKeyColumnName($mapping['sourceEntity'], $joinColumn['referencedColumnName']);
|
||||
|
||||
@@ -297,6 +297,10 @@ class DatabaseDriver implements MappingDriver
|
||||
$associationMapping['fieldName'] = $this->getFieldNameForColumn($tableName, $localColumn, true);
|
||||
$associationMapping['targetEntity'] = $this->getClassNameForTable($foreignTable);
|
||||
|
||||
if (isset($metadata->fieldMappings[$associationMapping['fieldName']])) {
|
||||
$associationMapping['fieldName'] = $associationMapping['fieldName'] . "2";
|
||||
}
|
||||
|
||||
if ($primaryKeyColumns && in_array($localColumn, $primaryKeyColumns)) {
|
||||
$associationMapping['id'] = true;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ class XmlDriver extends FileDriver
|
||||
if (isset($xmlRoot['repository-class'])) {
|
||||
$metadata->setCustomRepositoryClass((string)$xmlRoot['repository-class']);
|
||||
}
|
||||
if (isset($xmlRoot['read-only']) && $xmlRoot['read-only'] == "true") {
|
||||
if (isset($xmlRoot['read-only']) && $this->evaluateBoolean($xmlRoot['read-only'])) {
|
||||
$metadata->markReadOnly();
|
||||
}
|
||||
} else if ($xmlRoot->getName() == 'mapped-superclass') {
|
||||
@@ -241,7 +241,7 @@ class XmlDriver extends FileDriver
|
||||
// Evaluate <id ...> mappings
|
||||
$associationIds = array();
|
||||
foreach ($xmlRoot->id as $idElement) {
|
||||
if ((bool)$idElement['association-key'] == true) {
|
||||
if (isset($idElement['association-key']) && $this->evaluateBoolean($idElement['association-key'])) {
|
||||
$associationIds[(string)$idElement['name']] = true;
|
||||
continue;
|
||||
}
|
||||
@@ -334,7 +334,7 @@ class XmlDriver extends FileDriver
|
||||
}
|
||||
|
||||
if (isset($oneToOneElement['orphan-removal'])) {
|
||||
$mapping['orphanRemoval'] = (bool)$oneToOneElement['orphan-removal'];
|
||||
$mapping['orphanRemoval'] = $this->evaluateBoolean($oneToOneElement['orphan-removal']);
|
||||
}
|
||||
|
||||
$metadata->mapOneToOne($mapping);
|
||||
@@ -359,7 +359,7 @@ class XmlDriver extends FileDriver
|
||||
}
|
||||
|
||||
if (isset($oneToManyElement['orphan-removal'])) {
|
||||
$mapping['orphanRemoval'] = (bool)$oneToManyElement['orphan-removal'];
|
||||
$mapping['orphanRemoval'] = $this->evaluateBoolean($oneToManyElement['orphan-removal']);
|
||||
}
|
||||
|
||||
if (isset($oneToManyElement->{'order-by'})) {
|
||||
@@ -433,7 +433,7 @@ class XmlDriver extends FileDriver
|
||||
}
|
||||
|
||||
if (isset($manyToManyElement['orphan-removal'])) {
|
||||
$mapping['orphanRemoval'] = (bool)$manyToManyElement['orphan-removal'];
|
||||
$mapping['orphanRemoval'] = $this->evaluateBoolean($manyToManyElement['orphan-removal']);
|
||||
}
|
||||
|
||||
if (isset($manyToManyElement['mapped-by'])) {
|
||||
@@ -594,11 +594,11 @@ class XmlDriver extends FileDriver
|
||||
);
|
||||
|
||||
if (isset($joinColumnElement['unique'])) {
|
||||
$joinColumn['unique'] = ((string)$joinColumnElement['unique'] == "false") ? false : true;
|
||||
$joinColumn['unique'] = $this->evaluateBoolean($joinColumnElement['unique']);
|
||||
}
|
||||
|
||||
if (isset($joinColumnElement['nullable'])) {
|
||||
$joinColumn['nullable'] = ((string)$joinColumnElement['nullable'] == "false") ? false : true;
|
||||
$joinColumn['nullable'] = $this->evaluateBoolean($joinColumnElement['nullable']);
|
||||
}
|
||||
|
||||
if (isset($joinColumnElement['on-delete'])) {
|
||||
@@ -645,11 +645,11 @@ class XmlDriver extends FileDriver
|
||||
}
|
||||
|
||||
if (isset($fieldMapping['unique'])) {
|
||||
$mapping['unique'] = ((string) $fieldMapping['unique'] == "false") ? false : true;
|
||||
$mapping['unique'] = $this->evaluateBoolean($fieldMapping['unique']);
|
||||
}
|
||||
|
||||
if (isset($fieldMapping['nullable'])) {
|
||||
$mapping['nullable'] = ((string) $fieldMapping['nullable'] == "false") ? false : true;
|
||||
$mapping['nullable'] = $this->evaluateBoolean($fieldMapping['nullable']);
|
||||
}
|
||||
|
||||
if (isset($fieldMapping['version']) && $fieldMapping['version']) {
|
||||
@@ -710,4 +710,12 @@ class XmlDriver extends FileDriver
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function evaluateBoolean($element)
|
||||
{
|
||||
$flag = (string)$element;
|
||||
|
||||
return ($flag === true || $flag == "true" || $flag == "1");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -198,6 +198,7 @@ class YamlDriver extends FileDriver
|
||||
|
||||
if (is_string($index['columns'])) {
|
||||
$columns = explode(',', $index['columns']);
|
||||
$columns = array_map('trim', $columns);
|
||||
} else {
|
||||
$columns = $index['columns'];
|
||||
}
|
||||
@@ -217,6 +218,7 @@ class YamlDriver extends FileDriver
|
||||
|
||||
if (is_string($unique['columns'])) {
|
||||
$columns = explode(',', $unique['columns']);
|
||||
$columns = array_map('trim', $columns);
|
||||
} else {
|
||||
$columns = $unique['columns'];
|
||||
}
|
||||
@@ -628,7 +630,7 @@ class YamlDriver extends FileDriver
|
||||
$mapping['type'] = $column['type'];
|
||||
|
||||
if (isset($params[1])) {
|
||||
$column['length'] = substr($params[1], 0, strlen($params[1]) - 1);
|
||||
$column['length'] = (integer) substr($params[1], 0, strlen($params[1]) - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class MappingException extends \Doctrine\ORM\ORMException
|
||||
|
||||
public static function identifierRequired($entityName)
|
||||
{
|
||||
if (null !== ($parent = get_parent_class($entityName))) {
|
||||
if (false !== ($parent = get_parent_class($entityName))) {
|
||||
return new self(sprintf(
|
||||
'No identifier/primary key specified for Entity "%s" sub class of "%s". Every Entity must have an identifier/primary key.',
|
||||
$entityName, $parent
|
||||
@@ -206,7 +206,7 @@ class MappingException extends \Doctrine\ORM\ORMException
|
||||
|
||||
public static function classIsNotAValidEntityOrMappedSuperClass($className)
|
||||
{
|
||||
if (null !== ($parent = get_parent_class($className))) {
|
||||
if (false !== ($parent = get_parent_class($className))) {
|
||||
return new self(sprintf(
|
||||
'Class "%s" sub class of "%s" is not a valid entity or mapped super class.',
|
||||
$className, $parent
|
||||
|
||||
@@ -655,7 +655,7 @@ final class PersistentCollection implements Collection, Selectable
|
||||
|
||||
$this->initialized = true; // direct call, {@link initialize()} is too expensive
|
||||
|
||||
if ($this->association['isOwningSide']) {
|
||||
if ($this->association['isOwningSide'] && $this->owner) {
|
||||
$this->changed();
|
||||
|
||||
$uow->scheduleCollectionDeletion($this);
|
||||
|
||||
@@ -88,7 +88,7 @@ class BasicEntityPersister
|
||||
*/
|
||||
static private $comparisonMap = array(
|
||||
Comparison::EQ => '= %s',
|
||||
Comparison::IS => '= %s',
|
||||
Comparison::IS => 'IS %s',
|
||||
Comparison::NEQ => '!= %s',
|
||||
Comparison::GT => '> %s',
|
||||
Comparison::GTE => '>= %s',
|
||||
@@ -659,12 +659,13 @@ class BasicEntityPersister
|
||||
* @param array $hints Hints for entity creation.
|
||||
* @param int $lockMode
|
||||
* @param int $limit Limit number of results
|
||||
* @param array $orderBy Criteria to order by
|
||||
* @return object The loaded and managed entity instance or NULL if the entity can not be found.
|
||||
* @todo Check identity map? loadById method? Try to guess whether $criteria is the id?
|
||||
*/
|
||||
public function load(array $criteria, $entity = null, $assoc = null, array $hints = array(), $lockMode = 0, $limit = null)
|
||||
public function load(array $criteria, $entity = null, $assoc = null, array $hints = array(), $lockMode = 0, $limit = null, array $orderBy = null)
|
||||
{
|
||||
$sql = $this->_getSelectEntitiesSQL($criteria, $assoc, $lockMode, $limit);
|
||||
$sql = $this->_getSelectEntitiesSQL($criteria, $assoc, $lockMode, $limit, null, $orderBy);
|
||||
list($params, $types) = $this->expandParameters($criteria);
|
||||
$stmt = $this->_conn->executeQuery($sql, $params, $types);
|
||||
|
||||
@@ -1699,7 +1700,11 @@ class BasicEntityPersister
|
||||
$idValues = $class->getIdentifierValues($value);
|
||||
}
|
||||
|
||||
$value = $idValues[key($idValues)];
|
||||
$key = key($idValues);
|
||||
|
||||
if (null !== $key){
|
||||
$value = $idValues[$key];
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
|
||||
@@ -468,7 +468,8 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
|
||||
}
|
||||
} else if ($this->_class->name != $this->_class->rootEntityName ||
|
||||
! $this->_class->isIdGeneratorIdentity() || $this->_class->identifier[0] != $name) {
|
||||
$columns[] = $this->quoteStrategy->getColumnName($name, $this->_class, $this->_platform);
|
||||
$columns[] = $this->quoteStrategy->getColumnName($name, $this->_class, $this->_platform);
|
||||
$this->_columnTypes[$name] = $this->_class->fieldMappings[$name]['type'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,6 @@ class JoinClassPathExpression extends Node
|
||||
|
||||
public function dispatch($walker)
|
||||
{
|
||||
return $sqlWalker->walkJoinPathExpression($this);
|
||||
return $walker->walkJoinPathExpression($this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1007,8 +1007,13 @@ class SqlWalker implements TreeWalker
|
||||
|
||||
switch (true) {
|
||||
case ($joinDeclaration instanceof \Doctrine\ORM\Query\AST\RangeVariableDeclaration):
|
||||
$class = $this->em->getClassMetadata($joinDeclaration->abstractSchemaName);
|
||||
$condExprConjunction = $class->isInheritanceTypeJoined() && $joinType != AST\Join::JOIN_TYPE_LEFT && $joinType != AST\Join::JOIN_TYPE_LEFTOUTER
|
||||
? ' AND '
|
||||
: ' ON ';
|
||||
|
||||
$sql .= $this->walkRangeVariableDeclaration($joinDeclaration)
|
||||
. ' ON (' . $this->walkConditionalExpression($join->conditionalExpression) . ')';
|
||||
. $condExprConjunction . '(' . $this->walkConditionalExpression($join->conditionalExpression) . ')';
|
||||
break;
|
||||
|
||||
case ($joinDeclaration instanceof \Doctrine\ORM\Query\AST\JoinAssociationDeclaration):
|
||||
@@ -1147,7 +1152,7 @@ class SqlWalker implements TreeWalker
|
||||
switch (true) {
|
||||
case ($expr instanceof AST\PathExpression):
|
||||
if ($expr->type !== AST\PathExpression::TYPE_STATE_FIELD) {
|
||||
throw QueryException::invalidPathExpression($expr->type);
|
||||
throw QueryException::invalidPathExpression($expr);
|
||||
}
|
||||
|
||||
$fieldName = $expr->field;
|
||||
@@ -1188,7 +1193,6 @@ class SqlWalker implements TreeWalker
|
||||
case ($expr instanceof AST\SimpleArithmeticExpression):
|
||||
case ($expr instanceof AST\ArithmeticTerm):
|
||||
case ($expr instanceof AST\ArithmeticFactor):
|
||||
case ($expr instanceof AST\ArithmeticPrimary):
|
||||
case ($expr instanceof AST\Literal):
|
||||
case ($expr instanceof AST\NullIfExpression):
|
||||
case ($expr instanceof AST\CoalesceExpression):
|
||||
@@ -1422,7 +1426,6 @@ class SqlWalker implements TreeWalker
|
||||
case ($expr instanceof AST\SimpleArithmeticExpression):
|
||||
case ($expr instanceof AST\ArithmeticTerm):
|
||||
case ($expr instanceof AST\ArithmeticFactor):
|
||||
case ($expr instanceof AST\ArithmeticPrimary):
|
||||
case ($expr instanceof AST\Literal):
|
||||
case ($expr instanceof AST\NullIfExpression):
|
||||
case ($expr instanceof AST\CoalesceExpression):
|
||||
@@ -1609,7 +1612,7 @@ class SqlWalker implements TreeWalker
|
||||
|
||||
if (count($filterClauses)) {
|
||||
if ($condSql) {
|
||||
$condSql .= ' AND ';
|
||||
$condSql = '(' . $condSql . ') AND ';
|
||||
}
|
||||
|
||||
$condSql .= implode(' AND ', $filterClauses);
|
||||
|
||||
@@ -157,6 +157,38 @@ class EntityGenerator
|
||||
Type::SIMPLE_ARRAY => 'array',
|
||||
);
|
||||
|
||||
/**
|
||||
* @var array Hash-map to handle generator types string.
|
||||
*/
|
||||
protected static $generatorStrategyMap = array(
|
||||
ClassMetadataInfo::GENERATOR_TYPE_AUTO => 'AUTO',
|
||||
ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE => 'SEQUENCE',
|
||||
ClassMetadataInfo::GENERATOR_TYPE_TABLE => 'TABLE',
|
||||
ClassMetadataInfo::GENERATOR_TYPE_IDENTITY => 'IDENTITY',
|
||||
ClassMetadataInfo::GENERATOR_TYPE_NONE => 'NONE',
|
||||
ClassMetadataInfo::GENERATOR_TYPE_UUID => 'UUID',
|
||||
ClassMetadataInfo::GENERATOR_TYPE_CUSTOM => 'CUSTOM'
|
||||
);
|
||||
|
||||
/**
|
||||
* @var array Hash-map to handle the change tracking policy string.
|
||||
*/
|
||||
protected static $changeTrackingPolicyMap = array(
|
||||
ClassMetadataInfo::CHANGETRACKING_DEFERRED_IMPLICIT => 'DEFERRED_IMPLICIT',
|
||||
ClassMetadataInfo::CHANGETRACKING_DEFERRED_EXPLICIT => 'DEFERRED_EXPLICIT',
|
||||
ClassMetadataInfo::CHANGETRACKING_NOTIFY => 'NOTIFY',
|
||||
);
|
||||
|
||||
/**
|
||||
* @var array Hash-map to handle the inheritance type string.
|
||||
*/
|
||||
protected static $inheritanceTypeMap = array(
|
||||
ClassMetadataInfo::INHERITANCE_TYPE_NONE => 'NONE',
|
||||
ClassMetadataInfo::INHERITANCE_TYPE_JOINED => 'JOINED',
|
||||
ClassMetadataInfo::INHERITANCE_TYPE_SINGLE_TABLE => 'SINGLE_TABLE',
|
||||
ClassMetadataInfo::INHERITANCE_TYPE_TABLE_PER_CLASS => 'TABLE_PER_CLASS',
|
||||
);
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@@ -672,7 +704,7 @@ public function __construct()
|
||||
{
|
||||
$lines = array();
|
||||
$lines[] = '/**';
|
||||
$lines[] = ' * '.$metadata->name;
|
||||
$lines[] = ' * ' . $this->getClassName($metadata);
|
||||
|
||||
if ($this->generateAnnotations) {
|
||||
$lines[] = ' *';
|
||||
@@ -909,9 +941,14 @@ public function __construct()
|
||||
$var = sprintf('%sMethodTemplate', $type);
|
||||
$template = self::$$var;
|
||||
|
||||
$methodTypeHint = null;
|
||||
$types = Type::getTypesMap();
|
||||
$variableType = $typeHint ? $this->getType($typeHint) . ' ' : null;
|
||||
$methodTypeHint = $typeHint && ! isset($types[$typeHint]) ? '\\' . $typeHint . ' ' : null;
|
||||
|
||||
if ($typeHint && ! isset($types[$typeHint])) {
|
||||
$variableType = '\\' . ltrim($variableType, '\\');
|
||||
$methodTypeHint = '\\' . $typeHint . ' ';
|
||||
}
|
||||
|
||||
$replacements = array(
|
||||
'<description>' => ucfirst($type) . ' ' . $fieldName,
|
||||
@@ -991,9 +1028,9 @@ public function __construct()
|
||||
$lines[] = $this->spaces . '/**';
|
||||
|
||||
if ($associationMapping['type'] & ClassMetadataInfo::TO_MANY) {
|
||||
$lines[] = $this->spaces . ' * @var \Doctrine\Common\Collections\ArrayCollection';
|
||||
$lines[] = $this->spaces . ' * @var \Doctrine\Common\Collections\Collection';
|
||||
} else {
|
||||
$lines[] = $this->spaces . ' * @var ' . $associationMapping['targetEntity'];
|
||||
$lines[] = $this->spaces . ' * @var \\' . ltrim($associationMapping['targetEntity'], '\\');
|
||||
}
|
||||
|
||||
if ($this->generateAnnotations) {
|
||||
@@ -1080,17 +1117,23 @@ public function __construct()
|
||||
$lines[] = $this->spaces . ' * @' . $this->annotationsPrefix . 'JoinTable(' . implode(', ', $joinTable) . ',';
|
||||
$lines[] = $this->spaces . ' * joinColumns={';
|
||||
|
||||
$joinColumnsLines = array();
|
||||
|
||||
foreach ($associationMapping['joinTable']['joinColumns'] as $joinColumn) {
|
||||
$lines[] = $this->spaces . ' * ' . $this->generateJoinColumnAnnotation($joinColumn);
|
||||
$joinColumnsLines[] = $this->spaces . ' * ' . $this->generateJoinColumnAnnotation($joinColumn);
|
||||
}
|
||||
|
||||
$lines[] = implode(",". PHP_EOL, $joinColumnsLines);
|
||||
$lines[] = $this->spaces . ' * },';
|
||||
$lines[] = $this->spaces . ' * inverseJoinColumns={';
|
||||
|
||||
$inverseJoinColumnsLines = array();
|
||||
|
||||
foreach ($associationMapping['joinTable']['inverseJoinColumns'] as $joinColumn) {
|
||||
$lines[] = $this->spaces . ' * ' . $this->generateJoinColumnAnnotation($joinColumn);
|
||||
$inverseJoinColumnsLines[] = $this->spaces . ' * ' . $this->generateJoinColumnAnnotation($joinColumn);
|
||||
}
|
||||
|
||||
$lines[] = implode(",". PHP_EOL, $inverseJoinColumnsLines);
|
||||
$lines[] = $this->spaces . ' * }';
|
||||
$lines[] = $this->spaces . ' * )';
|
||||
}
|
||||
@@ -1116,7 +1159,7 @@ public function __construct()
|
||||
{
|
||||
$lines = array();
|
||||
$lines[] = $this->spaces . '/**';
|
||||
$lines[] = $this->spaces . ' * @var ' . $this->getType($fieldMapping['type']) . ' $' . $fieldMapping['fieldName'];
|
||||
$lines[] = $this->spaces . ' * @var ' . $this->getType($fieldMapping['type']);
|
||||
|
||||
if ($this->generateAnnotations) {
|
||||
$lines[] = $this->spaces . ' *';
|
||||
@@ -1203,63 +1246,45 @@ public function __construct()
|
||||
return implode("\n", $lines);
|
||||
}
|
||||
|
||||
private function getInheritanceTypeString($type)
|
||||
/**
|
||||
* @param integer $type The inheritance type used by the class and it's subclasses.
|
||||
* @return string The literal string for the inheritance type.
|
||||
* @throws \InvalidArgumentException When the inheritance type does not exists.
|
||||
*/
|
||||
protected function getInheritanceTypeString($type)
|
||||
{
|
||||
switch ($type) {
|
||||
case ClassMetadataInfo::INHERITANCE_TYPE_NONE:
|
||||
return 'NONE';
|
||||
|
||||
case ClassMetadataInfo::INHERITANCE_TYPE_JOINED:
|
||||
return 'JOINED';
|
||||
|
||||
case ClassMetadataInfo::INHERITANCE_TYPE_SINGLE_TABLE:
|
||||
return 'SINGLE_TABLE';
|
||||
|
||||
case ClassMetadataInfo::INHERITANCE_TYPE_TABLE_PER_CLASS:
|
||||
return 'PER_CLASS';
|
||||
|
||||
default:
|
||||
throw new \InvalidArgumentException('Invalid provided InheritanceType: ' . $type);
|
||||
if ( ! isset(self::$inheritanceTypeMap[$type])) {
|
||||
throw new \InvalidArgumentException(sprintf('Invalid provided InheritanceType: %s', $type));
|
||||
}
|
||||
|
||||
return self::$inheritanceTypeMap[$type];
|
||||
}
|
||||
|
||||
private function getChangeTrackingPolicyString($policy)
|
||||
/**
|
||||
* @param integer $type The policy used for change-tracking for the mapped class.
|
||||
* @return string The literal string for the change-tracking type.
|
||||
* @throws \InvalidArgumentException When the change-tracking type does not exists.
|
||||
*/
|
||||
protected function getChangeTrackingPolicyString($type)
|
||||
{
|
||||
switch ($policy) {
|
||||
case ClassMetadataInfo::CHANGETRACKING_DEFERRED_IMPLICIT:
|
||||
return 'DEFERRED_IMPLICIT';
|
||||
|
||||
case ClassMetadataInfo::CHANGETRACKING_DEFERRED_EXPLICIT:
|
||||
return 'DEFERRED_EXPLICIT';
|
||||
|
||||
case ClassMetadataInfo::CHANGETRACKING_NOTIFY:
|
||||
return 'NOTIFY';
|
||||
|
||||
default:
|
||||
throw new \InvalidArgumentException('Invalid provided ChangeTrackingPolicy: ' . $policy);
|
||||
if ( ! isset(self::$changeTrackingPolicyMap[$type])) {
|
||||
throw new \InvalidArgumentException(sprintf('Invalid provided ChangeTrackingPolicy: %s', $type));
|
||||
}
|
||||
|
||||
return self::$changeTrackingPolicyMap[$type];
|
||||
}
|
||||
|
||||
private function getIdGeneratorTypeString($type)
|
||||
/**
|
||||
* @param integer $type The generator to use for the mapped class.
|
||||
* @return string The literal string for the generetor type.
|
||||
* @throws \InvalidArgumentException When the generator type does not exists.
|
||||
*/
|
||||
protected function getIdGeneratorTypeString($type)
|
||||
{
|
||||
switch ($type) {
|
||||
case ClassMetadataInfo::GENERATOR_TYPE_AUTO:
|
||||
return 'AUTO';
|
||||
|
||||
case ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE:
|
||||
return 'SEQUENCE';
|
||||
|
||||
case ClassMetadataInfo::GENERATOR_TYPE_TABLE:
|
||||
return 'TABLE';
|
||||
|
||||
case ClassMetadataInfo::GENERATOR_TYPE_IDENTITY:
|
||||
return 'IDENTITY';
|
||||
|
||||
case ClassMetadataInfo::GENERATOR_TYPE_NONE:
|
||||
return 'NONE';
|
||||
|
||||
default:
|
||||
throw new \InvalidArgumentException('Invalid provided IdGeneratorType: ' . $type);
|
||||
if ( ! isset(self::$generatorStrategyMap[$type])) {
|
||||
throw new \InvalidArgumentException(sprintf('Invalid provided IdGeneratorType: %s', $type));
|
||||
}
|
||||
|
||||
return self::$generatorStrategyMap[$type];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,10 +76,12 @@ class XmlExporter extends AbstractExporter
|
||||
}
|
||||
|
||||
if ($metadata->discriminatorColumn) {
|
||||
$discriminatorColumnXml = $root->addChild('discriminiator-column');
|
||||
$discriminatorColumnXml = $root->addChild('discriminator-column');
|
||||
$discriminatorColumnXml->addAttribute('name', $metadata->discriminatorColumn['name']);
|
||||
$discriminatorColumnXml->addAttribute('type', $metadata->discriminatorColumn['type']);
|
||||
$discriminatorColumnXml->addAttribute('length', $metadata->discriminatorColumn['length']);
|
||||
if (isset($metadata->discriminatorColumn['length'])) {
|
||||
$discriminatorColumnXml->addAttribute('length', $metadata->discriminatorColumn['length']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($metadata->discriminatorMap) {
|
||||
@@ -109,9 +111,9 @@ class XmlExporter extends AbstractExporter
|
||||
if (isset($metadata->table['uniqueConstraints'])) {
|
||||
$uniqueConstraintsXml = $root->addChild('unique-constraints');
|
||||
|
||||
foreach ($metadata->table['uniqueConstraints'] as $unique) {
|
||||
foreach ($metadata->table['uniqueConstraints'] as $name => $unique) {
|
||||
$uniqueConstraintXml = $uniqueConstraintsXml->addChild('unique-constraint');
|
||||
$uniqueConstraintXml->addAttribute('name', $unique['name']);
|
||||
$uniqueConstraintXml->addAttribute('name', $name);
|
||||
$uniqueConstraintXml->addAttribute('columns', implode(',', $unique['columns']));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,9 @@
|
||||
|
||||
namespace Doctrine\ORM\Tools\Pagination;
|
||||
|
||||
use Doctrine\ORM\Query\SqlWalker,
|
||||
Doctrine\ORM\Query\AST\SelectStatement;
|
||||
use Doctrine\ORM\Query\SqlWalker;
|
||||
use Doctrine\ORM\Query\AST\SelectStatement;
|
||||
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
|
||||
|
||||
/**
|
||||
* Wrap the query in order to select root entity IDs for pagination
|
||||
@@ -85,7 +86,7 @@ class LimitSubqueryOutputWalker extends SqlWalker
|
||||
*/
|
||||
public function walkSelectStatement(SelectStatement $AST)
|
||||
{
|
||||
$sql = parent::walkSelectStatement($AST);
|
||||
$innerSql = parent::walkSelectStatement($AST);
|
||||
|
||||
// Find out the SQL alias of the identifier column of the root entity
|
||||
// It may be possible to make this work with multiple root entities but that
|
||||
@@ -133,7 +134,12 @@ class LimitSubqueryOutputWalker extends SqlWalker
|
||||
|
||||
// Build the counter query
|
||||
$sql = sprintf('SELECT DISTINCT %s FROM (%s) dctrn_result',
|
||||
implode(', ', $sqlIdentifier), $sql);
|
||||
implode(', ', $sqlIdentifier), $innerSql);
|
||||
|
||||
if ($this->platform instanceof PostgreSqlPlatform) {
|
||||
//http://www.doctrine-project.org/jira/browse/DDC-1958
|
||||
$this->getPostgresqlSql($AST, $sqlIdentifier, $innerSql, $sql);
|
||||
}
|
||||
|
||||
// Apply the limit and offset
|
||||
$sql = $this->platform->modifyLimitQuery(
|
||||
@@ -150,4 +156,47 @@ class LimitSubqueryOutputWalker extends SqlWalker
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate new SQL for postgresql if necessary
|
||||
*
|
||||
* @param SelectStatement $AST
|
||||
* @param array sqlIdentifier
|
||||
* @param string $sql
|
||||
*/
|
||||
public function getPostgresqlSql(SelectStatement $AST, array $sqlIdentifier, $innerSql, &$sql)
|
||||
{
|
||||
// For every order by, find out the SQL alias by inspecting the ResultSetMapping
|
||||
$sqlOrderColumns = array();
|
||||
$orderBy = array();
|
||||
if (isset($AST->orderByClause)) {
|
||||
foreach ($AST->orderByClause->orderByItems as $item) {
|
||||
$possibleAliases = array_keys($this->rsm->fieldMappings, $item->expression->field);
|
||||
|
||||
foreach ($possibleAliases as $alias) {
|
||||
if ($this->rsm->columnOwnerMap[$alias] == $item->expression->identificationVariable) {
|
||||
$sqlOrderColumns[] = $alias;
|
||||
$orderBy[] = $alias . ' ' . $item->type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//remove identifier aliases
|
||||
$sqlOrderColumns = array_diff($sqlOrderColumns, $sqlIdentifier);
|
||||
}
|
||||
|
||||
//we don't need orderBy in inner query
|
||||
//However at least on 5.4.6 I'm getting a segmentation fault and thus we don't clear it for now
|
||||
/*$AST->orderByClause = null;
|
||||
$innerSql = parent::walkSelectStatement($AST);*/
|
||||
|
||||
if (count($orderBy)) {
|
||||
$sql = sprintf(
|
||||
'SELECT DISTINCT %s FROM (%s) dctrn_result ORDER BY %s',
|
||||
implode(', ', array_merge($sqlIdentifier, $sqlOrderColumns)),
|
||||
$innerSql,
|
||||
implode(', ', $orderBy)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,15 +178,10 @@ class Paginator implements \Countable, \IteratorAggregate
|
||||
return new \ArrayIterator(array());
|
||||
}
|
||||
|
||||
$namespace = WhereInWalker::PAGINATOR_ID_ALIAS;
|
||||
|
||||
$whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\WhereInWalker'));
|
||||
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, count($ids));
|
||||
$whereInQuery->setFirstResult(null)->setMaxResults(null);
|
||||
foreach ($ids as $i => $id) {
|
||||
$i++;
|
||||
$whereInQuery->setParameter("{$namespace}_{$i}", $id);
|
||||
}
|
||||
$whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, $ids);
|
||||
|
||||
$result = $whereInQuery->getResult($this->query->getHydrationMode());
|
||||
} else {
|
||||
|
||||
@@ -102,11 +102,8 @@ class WhereInWalker extends TreeWalkerAdapter
|
||||
array($pathExpression)
|
||||
);
|
||||
$expression = new InExpression($arithmeticExpression);
|
||||
$ns = self::PAGINATOR_ID_ALIAS;
|
||||
$expression->literals[] = new InputParameter(":" . self::PAGINATOR_ID_ALIAS);
|
||||
|
||||
for ($i = 1; $i <= $count; $i++) {
|
||||
$expression->literals[] = new InputParameter(":{$ns}_$i");
|
||||
}
|
||||
} else {
|
||||
$expression = new NullComparisonExpression($pathExpression);
|
||||
$expression->not = false;
|
||||
|
||||
@@ -73,6 +73,7 @@ class ResolveTargetEntityListener
|
||||
$newMapping = $this->resolveTargetEntities[$mapping['targetEntity']];
|
||||
$newMapping = array_replace_recursive($mapping, $newMapping);
|
||||
$newMapping['fieldName'] = $mapping['fieldName'];
|
||||
|
||||
unset($classMetadata->associationMappings[$mapping['fieldName']]);
|
||||
|
||||
switch ($mapping['type']) {
|
||||
|
||||
@@ -385,6 +385,24 @@ class SchemaTool
|
||||
}
|
||||
|
||||
if (isset($mapping['options'])) {
|
||||
if (isset($mapping['options']['comment'])) {
|
||||
$options['comment'] = $mapping['options']['comment'];
|
||||
|
||||
unset($mapping['options']['comment']);
|
||||
}
|
||||
|
||||
if (isset($mapping['options']['unsigned'])) {
|
||||
$options['unsigned'] = $mapping['options']['unsigned'];
|
||||
|
||||
unset($mapping['options']['unsigned']);
|
||||
}
|
||||
|
||||
if (isset($mapping['options']['fixed'])) {
|
||||
$options['fixed'] = $mapping['options']['fixed'];
|
||||
|
||||
unset($mapping['options']['fixed']);
|
||||
}
|
||||
|
||||
$options['customSchemaOptions'] = $mapping['options'];
|
||||
}
|
||||
|
||||
@@ -546,6 +564,11 @@ class SchemaTool
|
||||
if (isset($joinColumn['nullable'])) {
|
||||
$columnOptions['notnull'] = !$joinColumn['nullable'];
|
||||
}
|
||||
|
||||
if (isset($fieldMapping['options'])) {
|
||||
$columnOptions['options'] = $fieldMapping['options'];
|
||||
}
|
||||
|
||||
if ($fieldMapping['type'] == "string" && isset($fieldMapping['length'])) {
|
||||
$columnOptions['length'] = $fieldMapping['length'];
|
||||
} else if ($fieldMapping['type'] == "decimal") {
|
||||
|
||||
@@ -980,7 +980,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->entityChangeSets[$oid]) {
|
||||
if (!empty($this->entityChangeSets[$oid])) {
|
||||
$persister->update($entity);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class Version
|
||||
/**
|
||||
* Current Doctrine Version
|
||||
*/
|
||||
const VERSION = '2.3.0';
|
||||
const VERSION = '2.3.1';
|
||||
|
||||
/**
|
||||
* Compares a Doctrine version with the current one.
|
||||
|
||||
2
lib/vendor/doctrine-dbal
vendored
2
lib/vendor/doctrine-dbal
vendored
Submodule lib/vendor/doctrine-dbal updated: 30dc433ea0...256a610961
@@ -22,6 +22,31 @@ class DatabaseDriverTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$this->_sm = $this->_em->getConnection()->getSchemaManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-2059
|
||||
*/
|
||||
public function testIssue2059()
|
||||
{
|
||||
if (!$this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) {
|
||||
$this->markTestSkipped('Platform does not support foreign keys.');
|
||||
}
|
||||
|
||||
$user = new \Doctrine\DBAL\Schema\Table("ddc2059_user");
|
||||
$user->addColumn('id', 'integer');
|
||||
$user->setPrimaryKey(array('id'));
|
||||
$project = new \Doctrine\DBAL\Schema\Table("ddc2059_project");
|
||||
$project->addColumn('id', 'integer');
|
||||
$project->addColumn('user_id', 'integer');
|
||||
$project->addColumn('user', 'string');
|
||||
$project->setPrimaryKey(array('id'));
|
||||
$project->addForeignKeyConstraint('ddc2059_user', array('user_id'), array('id'));
|
||||
|
||||
$metadata = $this->convertToClassMetadata(array($project, $user), array());
|
||||
|
||||
$this->assertTrue(isset($metadata['Ddc2059Project']->fieldMappings['user']));
|
||||
$this->assertTrue(isset($metadata['Ddc2059Project']->associationMappings['user2']));
|
||||
}
|
||||
|
||||
public function testLoadMetadataFromDatabase()
|
||||
{
|
||||
if (!$this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) {
|
||||
|
||||
@@ -344,6 +344,20 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$this->assertEquals($addressId, $address->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-1241
|
||||
*/
|
||||
public function testFindOneByOrderBy()
|
||||
{
|
||||
$this->loadFixture();
|
||||
|
||||
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
|
||||
$userAsc = $repos->findOneBy(array(), array("username" => "ASC"));
|
||||
$userDesc = $repos->findOneBy(array(), array("username" => "DESC"));
|
||||
|
||||
$this->assertNotSame($userAsc, $userDesc);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-817
|
||||
*/
|
||||
|
||||
@@ -453,6 +453,22 @@ class SQLFilterTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$this->assertEquals(1, count($query->getResult()));
|
||||
}
|
||||
|
||||
public function testWhereOrFilter()
|
||||
{
|
||||
$this->loadFixtureData();
|
||||
$query = $this->_em->createQuery('select ug from Doctrine\Tests\Models\CMS\CmsGroup ug WHERE 1=1 OR 1=1');
|
||||
|
||||
// We get two users before enabling the filter
|
||||
$this->assertEquals(2, count($query->getResult()));
|
||||
|
||||
$conf = $this->_em->getConfiguration();
|
||||
$conf->addFilter("group_prefix", "\Doctrine\Tests\ORM\Functional\CMSGroupPrefixFilter");
|
||||
$this->_em->getFilters()->enable("group_prefix")->setParameter("prefix", "bar_%", DBALType::STRING);
|
||||
|
||||
// We get one user after enabling the filter
|
||||
$this->assertEquals(1, count($query->getResult()));
|
||||
}
|
||||
|
||||
|
||||
private function loadLazyFixtureData()
|
||||
{
|
||||
|
||||
177
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php
Executable file
177
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php
Executable file
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||
|
||||
require_once __DIR__ . '/../../../TestInit.php';
|
||||
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
|
||||
/**
|
||||
* @group DDC-2012
|
||||
*/
|
||||
class DDC2012Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Type::addType(DDC2012TsVectorType::MYTYPE, __NAMESPACE__ . '\DDC2012TsVectorType');
|
||||
|
||||
DDC2012TsVectorType::$calls = array();
|
||||
|
||||
$this->_schemaTool->createSchema(array(
|
||||
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2012Item'),
|
||||
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2012ItemPerson'),
|
||||
));
|
||||
}
|
||||
|
||||
public function testIssue()
|
||||
{
|
||||
$item = new DDC2012ItemPerson();
|
||||
$item->tsv = array('word1', 'word2', 'word3');
|
||||
|
||||
$this->_em->persist($item);
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
|
||||
$item = $this->_em->find(get_class($item), $item->id);
|
||||
|
||||
$this->assertArrayHasKey('convertToDatabaseValueSQL', DDC2012TsVectorType::$calls);
|
||||
$this->assertArrayHasKey('convertToDatabaseValue', DDC2012TsVectorType::$calls);
|
||||
$this->assertArrayHasKey('convertToPHPValue', DDC2012TsVectorType::$calls);
|
||||
|
||||
$this->assertCount(1, DDC2012TsVectorType::$calls['convertToDatabaseValueSQL']);
|
||||
$this->assertCount(1, DDC2012TsVectorType::$calls['convertToDatabaseValue']);
|
||||
$this->assertCount(1, DDC2012TsVectorType::$calls['convertToPHPValue']);
|
||||
|
||||
$this->assertInstanceOf(__NAMESPACE__ . '\DDC2012Item', $item);
|
||||
$this->assertEquals(array('word1', 'word2', 'word3'), $item->tsv);
|
||||
|
||||
|
||||
$item->tsv = array('word1', 'word2');
|
||||
|
||||
$this->_em->persist($item);
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
|
||||
$item = $this->_em->find(get_class($item), $item->id);
|
||||
|
||||
$this->assertCount(2, DDC2012TsVectorType::$calls['convertToDatabaseValueSQL']);
|
||||
$this->assertCount(2, DDC2012TsVectorType::$calls['convertToDatabaseValue']);
|
||||
$this->assertCount(2, DDC2012TsVectorType::$calls['convertToPHPValue']);
|
||||
|
||||
$this->assertInstanceOf(__NAMESPACE__ . '\DDC2012Item', $item);
|
||||
$this->assertEquals(array('word1', 'word2'), $item->tsv);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Table(name="ddc2010_item")
|
||||
* @Entity
|
||||
* @InheritanceType("JOINED")
|
||||
* @DiscriminatorColumn(name="type_id", type="smallint")
|
||||
* @DiscriminatorMap({
|
||||
* 1 = "DDC2012ItemPerson"
|
||||
* })
|
||||
*/
|
||||
class DDC2012Item
|
||||
{
|
||||
/**
|
||||
* @Id
|
||||
* @GeneratedValue
|
||||
* @Column(type="integer")
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @Column(name="tsv", type="tsvector", nullable=true)
|
||||
*/
|
||||
public $tsv;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Table(name="ddc2010_item_person")
|
||||
* @Entity
|
||||
*/
|
||||
class DDC2012ItemPerson extends DDC2012Item
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
class DDC2012TsVectorType extends Type
|
||||
{
|
||||
const MYTYPE = 'tsvector';
|
||||
|
||||
public static $calls = array();
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
|
||||
{
|
||||
return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function convertToDatabaseValue($value, AbstractPlatform $platform)
|
||||
{
|
||||
if (is_array($value)) {
|
||||
$value = implode(" ", $value);
|
||||
}
|
||||
|
||||
self::$calls[__FUNCTION__][] = array(
|
||||
'value' => $value,
|
||||
'platform' => $platform,
|
||||
);
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function convertToPHPValue($value, AbstractPlatform $platform)
|
||||
{
|
||||
self::$calls[__FUNCTION__][] = array(
|
||||
'value' => $value,
|
||||
'platform' => $platform,
|
||||
);
|
||||
|
||||
return explode(" ", strtolower($value));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform)
|
||||
{
|
||||
self::$calls[__FUNCTION__][] = array(
|
||||
'sqlExpr' => $sqlExpr,
|
||||
'platform' => $platform,
|
||||
);
|
||||
|
||||
// changed to upper expression to keep the test compatible with other Databases
|
||||
//sprintf('to_tsvector(%s)', $sqlExpr);
|
||||
|
||||
return $platform->getUpperExpression($sqlExpr);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function canRequireSQLConversion()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return self::MYTYPE;
|
||||
}
|
||||
}
|
||||
29
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2074Test.php
Normal file
29
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2074Test.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\PersistentCollection;
|
||||
use Doctrine\Tests\Models\ECommerce\ECommerceCategory;
|
||||
use Doctrine\Tests\Models\ECommerce\ECommerceProduct;
|
||||
|
||||
/**
|
||||
* @group DDC-2074
|
||||
*/
|
||||
class DDC2074Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
{
|
||||
public function testShouldNotScheduleDeletionOnClonedInstances()
|
||||
{
|
||||
$class = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceProduct');
|
||||
$product = new ECommerceProduct();
|
||||
$category = new ECommerceCategory();
|
||||
$collection = new PersistentCollection($this->_em, $class, new ArrayCollection(array($category)));
|
||||
$collection->setOwner($product, $class->associationMappings['categories']);
|
||||
|
||||
$uow = $this->_em->getUnitOfWork();
|
||||
$clonedCollection = clone $collection;
|
||||
$clonedCollection->clear();
|
||||
|
||||
$this->assertEquals(0, count($uow->getScheduledCollectionDeletions()));
|
||||
}
|
||||
}
|
||||
52
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php
Normal file
52
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||
|
||||
use Doctrine\ORM\UnitOfWork;
|
||||
|
||||
require_once __DIR__ . '/../../../TestInit.php';
|
||||
|
||||
class DDC2182Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
{
|
||||
public function testPassColumnOptionsToJoinColumns()
|
||||
{
|
||||
if ($this->_em->getConnection()->getDatabasePlatform()->getName() != 'mysql') {
|
||||
$this->markTestSkipped("This test is useful for all databases, but designed only for mysql.");
|
||||
}
|
||||
|
||||
$sql = $this->_schemaTool->getCreateSchemaSql(array(
|
||||
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2182OptionParent'),
|
||||
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2182OptionChild'),
|
||||
));
|
||||
|
||||
$this->assertEquals("CREATE TABLE DDC2182OptionParent (id INT UNSIGNED NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDB", $sql[0]);
|
||||
$this->assertEquals("CREATE TABLE DDC2182OptionChild (id VARCHAR(255) NOT NULL, parent_id INT UNSIGNED DEFAULT NULL, INDEX IDX_B314D4AD727ACA70 (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDB", $sql[1]);
|
||||
$this->assertEquals("ALTER TABLE DDC2182OptionChild ADD CONSTRAINT FK_B314D4AD727ACA70 FOREIGN KEY (parent_id) REFERENCES DDC2182OptionParent (id)", $sql[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table
|
||||
*/
|
||||
class DDC2182OptionParent
|
||||
{
|
||||
/** @Id @Column(type="integer", options={"unsigned": true}) */
|
||||
private $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table
|
||||
*/
|
||||
class DDC2182OptionChild
|
||||
{
|
||||
/** @Id @Column */
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="DDC2182OptionParent")
|
||||
* @JoinColumn(referencedColumnName="id")
|
||||
*/
|
||||
private $parent;
|
||||
}
|
||||
@@ -54,4 +54,35 @@ class YamlMappingDriverTest extends AbstractMappingDriverTest
|
||||
$this->createClassMetadata('Doctrine\Tests\Models\Generic\SerializationModel');
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-2069
|
||||
*/
|
||||
public function testSpacesShouldBeIgnoredWhenUseExplode()
|
||||
{
|
||||
$metadata = $this->createClassMetadata(__NAMESPACE__.'\DDC2069Entity');
|
||||
$unique = $metadata->table['uniqueConstraints'][0]['columns'];
|
||||
$indexes = $metadata->table['indexes'][0]['columns'];
|
||||
|
||||
$nameField = $metadata->fieldMappings['name'];
|
||||
$valueField = $metadata->fieldMappings['value'];
|
||||
|
||||
$this->assertEquals('name', $unique[0]);
|
||||
$this->assertEquals('value', $unique[1]);
|
||||
|
||||
$this->assertEquals('value', $indexes[0]);
|
||||
$this->assertEquals('name', $indexes[1]);
|
||||
|
||||
$this->assertEquals(255, $nameField['length']);
|
||||
$this->assertEquals(255, $valueField['length']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class DDC2069Entity
|
||||
{
|
||||
public $id;
|
||||
|
||||
public $name;
|
||||
|
||||
public $value;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
Doctrine\Tests\ORM\Mapping\DDC2069Entity:
|
||||
type: entity
|
||||
id:
|
||||
id:
|
||||
fields:
|
||||
name:
|
||||
type: string ( 255 )
|
||||
value:
|
||||
type: string ( 255 )
|
||||
uniqueConstraints:
|
||||
0:
|
||||
columns: name, value
|
||||
indexes:
|
||||
0:
|
||||
columns: value, name
|
||||
@@ -7,6 +7,7 @@ use Doctrine\ORM\Persisters\BasicEntityPersister;
|
||||
use Doctrine\Tests\Models\CustomType\CustomTypeParent;
|
||||
use Doctrine\Tests\Models\CustomType\CustomTypeChild;
|
||||
use Doctrine\Tests\Models\CustomType\CustomTypeFriend;
|
||||
use Doctrine\Common\Collections\Expr\Comparison;
|
||||
|
||||
require_once __DIR__ . '/../../TestInit.php';
|
||||
|
||||
@@ -88,4 +89,13 @@ class BasicEntityPersisterTypeValueSqlTest extends \Doctrine\Tests\OrmTestCase
|
||||
|
||||
$this->assertEquals('t0."simple-entity-id" AS simpleentityid1, t0."simple-entity-value" AS simpleentityvalue2', $method->invoke($persister));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-2073
|
||||
*/
|
||||
public function testSelectConditionStatementIsNull()
|
||||
{
|
||||
$statement = $this->_persister->getSelectConditionStatementSQL('test', null, array(), Comparison::IS);
|
||||
$this->assertEquals('test IS ?', $statement);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,6 +143,19 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testSupportsJoinOnMultipleComponentsWithJoinedInheritanceType()
|
||||
{
|
||||
$this->assertSqlGeneration(
|
||||
'SELECT e FROM Doctrine\Tests\Models\Company\CompanyEmployee e JOIN Doctrine\Tests\Models\Company\CompanyManager m WITH e.id = m.id',
|
||||
'SELECT c0_.id AS id0, c0_.name AS name1, c1_.salary AS salary2, c1_.department AS department3, c1_.startDate AS startDate4, c0_.discr AS discr5 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id INNER JOIN company_managers c2_ INNER JOIN company_employees c3_ ON c2_.id = c3_.id INNER JOIN company_persons c4_ ON c2_.id = c4_.id AND (c0_.id = c4_.id)'
|
||||
);
|
||||
|
||||
$this->assertSqlGeneration(
|
||||
'SELECT e FROM Doctrine\Tests\Models\Company\CompanyEmployee e LEFT JOIN Doctrine\Tests\Models\Company\CompanyManager m WITH e.id = m.id',
|
||||
'SELECT c0_.id AS id0, c0_.name AS name1, c1_.salary AS salary2, c1_.department AS department3, c1_.startDate AS startDate4, c0_.discr AS discr5 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id LEFT JOIN company_managers c2_ INNER JOIN company_employees c3_ ON c2_.id = c3_.id INNER JOIN company_persons c4_ ON c2_.id = c4_.id ON (c0_.id = c4_.id)'
|
||||
);
|
||||
}
|
||||
|
||||
public function testSupportsSelectWithCollectionAssociationJoin()
|
||||
{
|
||||
$this->assertSqlGeneration(
|
||||
|
||||
@@ -167,6 +167,24 @@ class EntityGeneratorTest extends \Doctrine\Tests\OrmTestCase
|
||||
$this->assertTrue($reflClass->getMethod('getTest')->isPublic(), "Check for public visibility of method 'getTest' failed.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-2121
|
||||
*/
|
||||
public function testMethodDocBlockShouldStartWithBackSlash()
|
||||
{
|
||||
$metadata = $this->generateBookEntityFixture();
|
||||
$book = $this->newInstance($metadata);
|
||||
|
||||
$this->assertPhpDocVarType('\Doctrine\Common\Collections\Collection', new \ReflectionProperty($book, 'comments'));
|
||||
$this->assertPhpDocReturnType('\Doctrine\Common\Collections\Collection', new \ReflectionMethod($book, 'getComments'));
|
||||
$this->assertPhpDocParamType('\Doctrine\Tests\ORM\Tools\EntityGeneratorComment', new \ReflectionMethod($book, 'addComment'));
|
||||
$this->assertPhpDocParamType('\Doctrine\Tests\ORM\Tools\EntityGeneratorComment', new \ReflectionMethod($book, 'removeComment'));
|
||||
|
||||
$this->assertPhpDocVarType('\Doctrine\Tests\ORM\Tools\EntityGeneratorAuthor', new \ReflectionProperty($book, 'author'));
|
||||
$this->assertPhpDocReturnType('\Doctrine\Tests\ORM\Tools\EntityGeneratorAuthor', new \ReflectionMethod($book, 'getAuthor'));
|
||||
$this->assertPhpDocParamType('\Doctrine\Tests\ORM\Tools\EntityGeneratorAuthor', new \ReflectionMethod($book, 'setAuthor'));
|
||||
}
|
||||
|
||||
public function testEntityExtendsStdClass()
|
||||
{
|
||||
$this->_generator->setClassToExtend('stdClass');
|
||||
@@ -278,6 +296,131 @@ class EntityGeneratorTest extends \Doctrine\Tests\OrmTestCase
|
||||
$this->assertContains('@SequenceGenerator(sequenceName="DDC1784_ID_SEQ", allocationSize=1, initialValue=2)', $docComment);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-2079
|
||||
*/
|
||||
public function testGenerateEntityWithMultipleInverseJoinColumns()
|
||||
{
|
||||
$metadata = new ClassMetadataInfo($this->_namespace . '\DDC2079Entity');
|
||||
$metadata->namespace = $this->_namespace;
|
||||
$metadata->mapField(array('fieldName' => 'id', 'type' => 'integer', 'id' => true));
|
||||
$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE);
|
||||
$metadata->mapManyToMany(array(
|
||||
'fieldName' => 'centroCustos',
|
||||
'targetEntity' => 'DDC2079CentroCusto',
|
||||
'joinTable' => array(
|
||||
'name' => 'unidade_centro_custo',
|
||||
'joinColumns' => array(
|
||||
array('name' => 'idorcamento', 'referencedColumnName' => 'idorcamento'),
|
||||
array('name' => 'idunidade', 'referencedColumnName' => 'idunidade')
|
||||
),
|
||||
'inverseJoinColumns' => array(
|
||||
array('name' => 'idcentrocusto', 'referencedColumnName' => 'idcentrocusto'),
|
||||
array('name' => 'idpais', 'referencedColumnName' => 'idpais'),
|
||||
),
|
||||
),
|
||||
));
|
||||
$this->_generator->writeEntityClass($metadata, $this->_tmpDir);
|
||||
|
||||
$filename = $this->_tmpDir . DIRECTORY_SEPARATOR
|
||||
. $this->_namespace . DIRECTORY_SEPARATOR . 'DDC2079Entity.php';
|
||||
|
||||
$this->assertFileExists($filename);
|
||||
require_once $filename;
|
||||
|
||||
$property = new \ReflectionProperty($metadata->name, 'centroCustos');
|
||||
$docComment = $property->getDocComment();
|
||||
|
||||
//joinColumns
|
||||
$this->assertContains('@JoinColumn(name="idorcamento", referencedColumnName="idorcamento"),', $docComment);
|
||||
$this->assertContains('@JoinColumn(name="idunidade", referencedColumnName="idunidade")', $docComment);
|
||||
//inverseJoinColumns
|
||||
$this->assertContains('@JoinColumn(name="idcentrocusto", referencedColumnName="idcentrocusto"),', $docComment);
|
||||
$this->assertContains('@JoinColumn(name="idpais", referencedColumnName="idpais")', $docComment);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-2172
|
||||
*/
|
||||
public function testGetInheritanceTypeString()
|
||||
{
|
||||
$reflection = new \ReflectionClass('\Doctrine\ORM\Mapping\ClassMetadata');
|
||||
$method = new \ReflectionMethod($this->_generator, 'getInheritanceTypeString');
|
||||
$constants = $reflection->getConstants();
|
||||
$pattern = '/^INHERITANCE_TYPE_/';
|
||||
|
||||
$method->setAccessible(true);
|
||||
|
||||
foreach ($constants as $name => $value) {
|
||||
if( ! preg_match($pattern, $name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$expected = preg_replace($pattern, '', $name);
|
||||
$actual = $method->invoke($this->_generator, $value);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
$this->setExpectedException('\InvalidArgumentException', 'Invalid provided InheritanceType: INVALID');
|
||||
$method->invoke($this->_generator, 'INVALID');
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-2172
|
||||
*/
|
||||
public function testGetChangeTrackingPolicyString()
|
||||
{
|
||||
$reflection = new \ReflectionClass('\Doctrine\ORM\Mapping\ClassMetadata');
|
||||
$method = new \ReflectionMethod($this->_generator, 'getChangeTrackingPolicyString');
|
||||
$constants = $reflection->getConstants();
|
||||
$pattern = '/^CHANGETRACKING_/';
|
||||
|
||||
$method->setAccessible(true);
|
||||
|
||||
foreach ($constants as $name => $value) {
|
||||
if( ! preg_match($pattern, $name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$expected = preg_replace($pattern, '', $name);
|
||||
$actual = $method->invoke($this->_generator, $value);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
$this->setExpectedException('\InvalidArgumentException', 'Invalid provided ChangeTrackingPolicy: INVALID');
|
||||
$method->invoke($this->_generator, 'INVALID');
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-2172
|
||||
*/
|
||||
public function testGetIdGeneratorTypeString()
|
||||
{
|
||||
$reflection = new \ReflectionClass('\Doctrine\ORM\Mapping\ClassMetadata');
|
||||
$method = new \ReflectionMethod($this->_generator, 'getIdGeneratorTypeString');
|
||||
$constants = $reflection->getConstants();
|
||||
$pattern = '/^GENERATOR_TYPE_/';
|
||||
|
||||
$method->setAccessible(true);
|
||||
|
||||
foreach ($constants as $name => $value) {
|
||||
if( ! preg_match($pattern, $name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$expected = preg_replace($pattern, '', $name);
|
||||
$actual = $method->invoke($this->_generator, $value);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
$this->setExpectedException('\InvalidArgumentException', 'Invalid provided IdGeneratorType: INVALID');
|
||||
$method->invoke($this->_generator, 'INVALID');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getEntityTypeAliasDataProvider
|
||||
*
|
||||
|
||||
@@ -10,14 +10,42 @@ class LimitSubqueryOutputWalkerTest extends PaginationTestCase
|
||||
{
|
||||
$query = $this->entityManager->createQuery(
|
||||
'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p JOIN p.category c JOIN p.author a');
|
||||
$query->expireQueryCache(true);
|
||||
$limitQuery = clone $query;
|
||||
$limitQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\LimitSubqueryOutputWalker');
|
||||
|
||||
$this->assertEquals(
|
||||
"SELECT DISTINCT id0 FROM (SELECT m0_.id AS id0, c1_.id AS id1, a2_.id AS id2, a2_.name AS name3, m0_.author_id AS author_id4, m0_.category_id AS category_id5 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) dctrn_result", $limitQuery->getSql()
|
||||
"SELECT DISTINCT id0 FROM (SELECT m0_.id AS id0, m0_.title AS title1, c1_.id AS id2, a2_.id AS id3, a2_.name AS name4, m0_.author_id AS author_id5, m0_.category_id AS category_id6 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) dctrn_result", $limitQuery->getSql()
|
||||
);
|
||||
}
|
||||
|
||||
public function testLimitSubqueryWithSortPg()
|
||||
{
|
||||
$odp = $this->entityManager->getConnection()->getDatabasePlatform();
|
||||
$this->entityManager->getConnection()->setDatabasePlatform(new \Doctrine\DBAL\Platforms\PostgreSqlPlatform);
|
||||
|
||||
$query = $this->entityManager->createQuery(
|
||||
'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p JOIN p.category c JOIN p.author a ORDER BY p.title');
|
||||
$limitQuery = clone $query;
|
||||
$limitQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\LimitSubqueryOutputWalker');
|
||||
|
||||
$this->assertEquals(
|
||||
"SELECT DISTINCT id0, title1 FROM (SELECT m0_.id AS id0, m0_.title AS title1, c1_.id AS id2, a2_.id AS id3, a2_.name AS name4, m0_.author_id AS author_id5, m0_.category_id AS category_id6 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id ORDER BY m0_.title ASC) dctrn_result ORDER BY title1 ASC", $limitQuery->getSql()
|
||||
);
|
||||
|
||||
$this->entityManager->getConnection()->setDatabasePlatform($odp);
|
||||
}
|
||||
|
||||
public function testLimitSubqueryPg()
|
||||
{
|
||||
$odp = $this->entityManager->getConnection()->getDatabasePlatform();
|
||||
$this->entityManager->getConnection()->setDatabasePlatform(new \Doctrine\DBAL\Platforms\PostgreSqlPlatform);
|
||||
|
||||
$this->testLimitSubquery();
|
||||
|
||||
$this->entityManager->getConnection()->setDatabasePlatform($odp);
|
||||
}
|
||||
|
||||
public function testCountQuery_MixedResultsWithName()
|
||||
{
|
||||
$query = $this->entityManager->createQuery(
|
||||
|
||||
@@ -21,6 +21,18 @@ class LimitSubqueryWalkerTest extends PaginationTestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testLimitSubqueryWithSort()
|
||||
{
|
||||
$query = $this->entityManager->createQuery(
|
||||
'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p JOIN p.category c JOIN p.author a ORDER BY p.title');
|
||||
$limitQuery = clone $query;
|
||||
$limitQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\LimitSubqueryWalker'));
|
||||
|
||||
$this->assertEquals(
|
||||
"SELECT DISTINCT m0_.id AS id0, m0_.title AS title1 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id ORDER BY m0_.title ASC", $limitQuery->getSql()
|
||||
);
|
||||
}
|
||||
|
||||
public function testCountQuery_MixedResultsWithName()
|
||||
{
|
||||
$query = $this->entityManager->createQuery(
|
||||
|
||||
@@ -31,6 +31,8 @@ class MyBlogPost
|
||||
* @ManyToOne(targetEntity="Category")
|
||||
*/
|
||||
public $category;
|
||||
/** @column(type="string") */
|
||||
public $title;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,7 @@ class WhereInWalkerTest extends PaginationTestCase
|
||||
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10);
|
||||
|
||||
$this->assertEquals(
|
||||
"SELECT u0_.id AS id0, g1_.id AS id1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE u0_.id IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", $whereInQuery->getSql()
|
||||
"SELECT u0_.id AS id0, g1_.id AS id1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE u0_.id IN (?)", $whereInQuery->getSql()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class WhereInWalkerTest extends PaginationTestCase
|
||||
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10);
|
||||
|
||||
$this->assertEquals(
|
||||
"SELECT a0_.id AS id0, a0_.name AS name1, sum(a0_.name) AS sclr2 FROM Author a0_ WHERE a0_.id IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", $whereInQuery->getSql()
|
||||
"SELECT a0_.id AS id0, a0_.name AS name1, sum(a0_.name) AS sclr2 FROM Author a0_ WHERE a0_.id IN (?)", $whereInQuery->getSql()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ class WhereInWalkerTest extends PaginationTestCase
|
||||
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10);
|
||||
|
||||
$this->assertEquals(
|
||||
"SELECT u0_.id AS id0, g1_.id AS id1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE 1 = 1 AND u0_.id IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", $whereInQuery->getSql()
|
||||
"SELECT u0_.id AS id0, g1_.id AS id1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE 1 = 1 AND u0_.id IN (?)", $whereInQuery->getSql()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ class WhereInWalkerTest extends PaginationTestCase
|
||||
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10);
|
||||
|
||||
$this->assertEquals(
|
||||
"SELECT u0_.id AS id0, g1_.id AS id1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE 1 = 1 AND 2 = 2 AND u0_.id IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", $whereInQuery->getSql()
|
||||
"SELECT u0_.id AS id0, g1_.id AS id1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE 1 = 1 AND 2 = 2 AND u0_.id IN (?)", $whereInQuery->getSql()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ class WhereInWalkerTest extends PaginationTestCase
|
||||
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10);
|
||||
|
||||
$this->assertEquals(
|
||||
"SELECT u0_.id AS id0, g1_.id AS id1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (1 = 1 OR 2 = 2) AND u0_.id IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", $whereInQuery->getSql()
|
||||
"SELECT u0_.id AS id0, g1_.id AS id1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (1 = 1 OR 2 = 2) AND u0_.id IN (?)", $whereInQuery->getSql()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ class WhereInWalkerTest extends PaginationTestCase
|
||||
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10);
|
||||
|
||||
$this->assertEquals(
|
||||
"SELECT u0_.id AS id0, g1_.id AS id1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (1 = 1 OR 2 = 2) AND 3 = 3 AND u0_.id IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", $whereInQuery->getSql()
|
||||
"SELECT u0_.id AS id0, g1_.id AS id1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (1 = 1 OR 2 = 2) AND 3 = 3 AND u0_.id IN (?)", $whereInQuery->getSql()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ class WhereInWalkerTest extends PaginationTestCase
|
||||
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10);
|
||||
|
||||
$this->assertEquals(
|
||||
"SELECT u0_.id AS id0, g1_.id AS id1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (1 = 1 AND 2 = 2 OR 3 = 3) AND u0_.id IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", $whereInQuery->getSql()
|
||||
"SELECT u0_.id AS id0, g1_.id AS id1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (1 = 1 AND 2 = 2 OR 3 = 3) AND u0_.id IN (?)", $whereInQuery->getSql()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ class WhereInWalkerTest extends PaginationTestCase
|
||||
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10);
|
||||
|
||||
$this->assertEquals(
|
||||
"SELECT u0_.id AS id0, g1_.id AS id1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (NOT 1 = 2) AND u0_.id IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", $whereInQuery->getSql()
|
||||
"SELECT u0_.id AS id0, g1_.id AS id1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (NOT 1 = 2) AND u0_.id IN (?)", $whereInQuery->getSql()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,31 @@ class ResolveTargetEntityListenerTest extends \Doctrine\Tests\OrmTestCase
|
||||
$this->assertSame('Doctrine\Tests\ORM\Tools\ResolveTargetEntity', $meta['oneToMany']['targetEntity']);
|
||||
$this->assertSame('Doctrine\Tests\ORM\Tools\TargetEntity', $meta['oneToOne']['targetEntity']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-2109
|
||||
*/
|
||||
public function testAssertTableColumnsAreNotAddedInManyToMany()
|
||||
{
|
||||
$evm = $this->em->getEventManager();
|
||||
$this->listener->addResolveTargetEntity(
|
||||
'Doctrine\Tests\ORM\Tools\ResolveTargetInterface',
|
||||
'Doctrine\Tests\ORM\Tools\ResolveTargetEntity',
|
||||
array()
|
||||
);
|
||||
$this->listener->addResolveTargetEntity(
|
||||
'Doctrine\Tests\ORM\Tools\TargetInterface',
|
||||
'Doctrine\Tests\ORM\Tools\TargetEntity',
|
||||
array()
|
||||
);
|
||||
|
||||
$evm->addEventListener(Events::loadClassMetadata, $this->listener);
|
||||
$cm = $this->factory->getMetadataFor('Doctrine\Tests\ORM\Tools\ResolveTargetEntity');
|
||||
$meta = $cm->associationMappings['manyToMany'];
|
||||
|
||||
$this->assertSame('Doctrine\Tests\ORM\Tools\TargetEntity', $meta['targetEntity']);
|
||||
$this->assertEquals(array('resolvetargetentity_id', 'targetinterface_id'), $meta['joinTableColumns']);
|
||||
}
|
||||
}
|
||||
|
||||
interface ResolveTargetInterface
|
||||
|
||||
@@ -44,8 +44,8 @@ class SchemaToolTest extends \Doctrine\Tests\OrmTestCase
|
||||
$schema = $schemaTool->getSchemaFromMetadata($classes);
|
||||
|
||||
$expected = array('foo' => 'bar', 'baz' => array('key' => 'val'));
|
||||
|
||||
$this->assertEquals($expected, $schema->getTable('TestEntityWithAnnotationOptionsAttribute')->getOptions(), "options annotation are passed to the tables optionss");
|
||||
|
||||
$this->assertEquals($expected, $schema->getTable('TestEntityWithAnnotationOptionsAttribute')->getOptions(), "options annotation are passed to the tables options");
|
||||
$this->assertEquals($expected, $schema->getTable('TestEntityWithAnnotationOptionsAttribute')->getColumn('test')->getCustomSchemaOptions(), "options annotation are passed to the columns customSchemaOptions");
|
||||
}
|
||||
|
||||
|
||||
@@ -204,6 +204,29 @@ class UnitOfWorkTest extends \Doctrine\Tests\OrmTestCase
|
||||
$this->assertEquals(UnitOfWork::STATE_DETACHED, $this->_unitOfWork->getEntityState($ph2));
|
||||
$this->assertFalse($persister->isExistsCalled());
|
||||
}
|
||||
|
||||
/**
|
||||
* DDC-2086 [GH-484] Prevented "Undefined index" notice when updating.
|
||||
*/
|
||||
public function testNoUndefinedIndexNoticeOnScheduleForUpdateWithoutChanges()
|
||||
{
|
||||
// Setup fake persister and id generator
|
||||
$userPersister = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata("Doctrine\Tests\Models\Forum\ForumUser"));
|
||||
$userPersister->setMockIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_IDENTITY);
|
||||
$this->_unitOfWork->setEntityPersister('Doctrine\Tests\Models\Forum\ForumUser', $userPersister);
|
||||
|
||||
// Create a test user
|
||||
$user = new ForumUser();
|
||||
$user->name = 'Jasper';
|
||||
$this->_unitOfWork->persist($user);
|
||||
$this->_unitOfWork->commit();
|
||||
|
||||
// Schedule user for update without changes
|
||||
$this->_unitOfWork->scheduleForUpdate($user);
|
||||
|
||||
// This commit should not raise an E_NOTICE
|
||||
$this->_unitOfWork->commit();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -309,4 +332,4 @@ class VersionedAssignedIdentifierEntity
|
||||
* @Version @Column(type="integer")
|
||||
*/
|
||||
public $version;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user