mirror of
https://github.com/doctrine/orm.git
synced 2026-04-27 16:33:40 +02:00
Compare commits
76 Commits
2.3.0-BETA1
...
2.3.0-RC2
| Author | SHA1 | Date | |
|---|---|---|---|
| 9308afc9a5 | |||
| 1a81444b04 | |||
| d181fbc98d | |||
| 114e233d87 | |||
| bdb36a71c5 | |||
| 8c1d64372c | |||
| f4ba58358c | |||
| 131d3003a0 | |||
| 48e94343fd | |||
| 9d909cd583 | |||
| 3aaa90e1a8 | |||
| ece6a005bc | |||
| 641af15280 | |||
| 971865f271 | |||
| af08f05164 | |||
| 2e6b50bb53 | |||
| 185b4e0c41 | |||
| 5c585b4c02 | |||
| 787a208708 | |||
| f8a582d454 | |||
| 72ce9a7f37 | |||
| 04de52d4c9 | |||
| 17862d9a2a | |||
| c99c7b6694 | |||
| 104a76a6b1 | |||
| 79a04b295f | |||
| 3f2ddc60d4 | |||
| 3b3d762277 | |||
| 992b51eba7 | |||
| 5527e121ec | |||
| c55394c616 | |||
| 1676cf23c0 | |||
| 6dd3078153 | |||
| 00a5f18544 | |||
| 1e2eca1a7e | |||
| 7029d3738d | |||
| 7f68347c1f | |||
| e63575ea18 | |||
| e8d3fc73ff | |||
| 7c1235dedb | |||
| d7bdae3bbb | |||
| e2c40dc365 | |||
| dfa6ff64c4 | |||
| bcbef5670c | |||
| 354fa14df4 | |||
| afd8ea91e3 | |||
| ef27721db2 | |||
| 13d32e6de5 | |||
| bd1e6ac309 | |||
| 14bd794960 | |||
| 369a30ad3d | |||
| cebb820030 | |||
| ac9df05c92 | |||
| 04e6cc78cd | |||
| 2158a0788e | |||
| fc4a07c2b3 | |||
| 2389f77d91 | |||
| 1eaa822d2a | |||
| 9dd3b66fe6 | |||
| 1369e3d133 | |||
| 50dac4096a | |||
| aa0cb0b6d7 | |||
| 5b55739990 | |||
| 3e53d9d79c | |||
| 619d29adb2 | |||
| 68adc7fed3 | |||
| 98c4833afc | |||
| e5979b5ef2 | |||
| fb3c6f0e8f | |||
| 5b3eee8071 | |||
| 81f97e92d3 | |||
| 93cef61270 | |||
| a723b73929 | |||
| 34ac207b3c | |||
| c8fcd3f8a5 | |||
| a0ba420969 |
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "doctrine/orm",
|
||||
"type": "library","version":"2.3.0-BETA1",
|
||||
"type": "library",
|
||||
"description": "Object-Relational-Mapper for PHP",
|
||||
"keywords": ["orm", "database"],
|
||||
"homepage": "http://www.doctrine-project.org",
|
||||
|
||||
@@ -512,6 +512,20 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the custom hydrator modes in one pass.
|
||||
*
|
||||
* @param array An array of ($modeName => $hydrator)
|
||||
*/
|
||||
public function setCustomHydrationModes($modes)
|
||||
{
|
||||
$this->_attributes['customHydrationModes'] = array();
|
||||
|
||||
foreach ($modes as $modeName => $hydrator) {
|
||||
$this->addCustomHydrationMode($modeName, $hydrator);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the hydrator class for the given hydration mode name.
|
||||
*
|
||||
@@ -589,13 +603,13 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
*
|
||||
* @since 2.2
|
||||
* @param string $className
|
||||
* @throws ORMException If not is a \Doctrine\ORM\EntityRepository
|
||||
* @throws ORMException If not is a \Doctrine\Common\Persistence\ObjectRepository
|
||||
*/
|
||||
public function setDefaultRepositoryClassName($className)
|
||||
{
|
||||
$entityRepositoryClassName = 'Doctrine\ORM\EntityRepository';
|
||||
$reflectionClass = new \ReflectionClass($className);
|
||||
|
||||
if ($className !== $entityRepositoryClassName && ! is_subclass_of($className, $entityRepositoryClassName)) {
|
||||
if ( ! $reflectionClass->implementsInterface('Doctrine\Common\Persistence\ObjectRepository')) {
|
||||
throw ORMException::invalidEntityRepository($className);
|
||||
}
|
||||
|
||||
|
||||
@@ -354,21 +354,82 @@ class EntityManager implements ObjectManager
|
||||
|
||||
$this->unitOfWork->commit($entity);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds an Entity by its identifier.
|
||||
*
|
||||
* This is just a convenient shortcut for getRepository($entityName)->find($id).
|
||||
*
|
||||
* @param string $entityName
|
||||
* @param mixed $identifier
|
||||
* @param int $lockMode
|
||||
* @param int $lockVersion
|
||||
* @param mixed $id
|
||||
* @param integer $lockMode
|
||||
* @param integer $lockVersion
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function find($entityName, $identifier, $lockMode = LockMode::NONE, $lockVersion = null)
|
||||
public function find($entityName, $id, $lockMode = LockMode::NONE, $lockVersion = null)
|
||||
{
|
||||
return $this->getRepository($entityName)->find($identifier, $lockMode, $lockVersion);
|
||||
$class = $this->metadataFactory->getMetadataFor(ltrim($entityName, '\\'));
|
||||
|
||||
if ( ! is_array($id)) {
|
||||
$id = array($class->identifier[0] => $id);
|
||||
}
|
||||
|
||||
$sortedId = array();
|
||||
|
||||
foreach ($class->identifier as $identifier) {
|
||||
if ( ! isset($id[$identifier])) {
|
||||
throw ORMException::missingIdentifierField($class->name, $identifier);
|
||||
}
|
||||
|
||||
$sortedId[$identifier] = $id[$identifier];
|
||||
}
|
||||
|
||||
$unitOfWork = $this->getUnitOfWork();
|
||||
|
||||
// Check identity map first
|
||||
if (($entity = $unitOfWork->tryGetById($sortedId, $class->rootEntityName)) !== false) {
|
||||
if ( ! ($entity instanceof $class->name)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
switch ($lockMode) {
|
||||
case LockMode::OPTIMISTIC:
|
||||
$this->lock($entity, $lockMode, $lockVersion);
|
||||
break;
|
||||
|
||||
case LockMode::PESSIMISTIC_READ:
|
||||
case LockMode::PESSIMISTIC_WRITE:
|
||||
$persister = $unitOfWork->getEntityPersister($class->name);
|
||||
$persister->refresh($sortedId, $entity, $lockMode);
|
||||
break;
|
||||
}
|
||||
|
||||
return $entity; // Hit!
|
||||
}
|
||||
|
||||
$persister = $unitOfWork->getEntityPersister($class->name);
|
||||
|
||||
switch ($lockMode) {
|
||||
case LockMode::NONE:
|
||||
return $persister->load($sortedId);
|
||||
|
||||
case LockMode::OPTIMISTIC:
|
||||
if ( ! $class->isVersioned) {
|
||||
throw OptimisticLockException::notVersioned($class->name);
|
||||
}
|
||||
|
||||
$entity = $persister->load($sortedId);
|
||||
|
||||
$unitOfWork->lock($entity, $lockMode, $lockVersion);
|
||||
|
||||
return $entity;
|
||||
|
||||
default:
|
||||
if ( ! $this->getConnection()->isTransactionActive()) {
|
||||
throw TransactionRequiredException::transactionRequired();
|
||||
}
|
||||
|
||||
return $persister->load($sortedId, null, null, array(), $lockMode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,11 +42,6 @@ use Doctrine\Common\Collections\ExpressionBuilder;
|
||||
*/
|
||||
class EntityRepository implements ObjectRepository, Selectable
|
||||
{
|
||||
/**
|
||||
* @var Doctrine\Common\Collections\ExpressionBuilder
|
||||
*/
|
||||
private static $expressionBuilder;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@@ -125,71 +120,15 @@ class EntityRepository implements ObjectRepository, Selectable
|
||||
/**
|
||||
* Finds an entity by its primary key / identifier.
|
||||
*
|
||||
* @param $id The identifier.
|
||||
* @param int $lockMode
|
||||
* @param int $lockVersion
|
||||
* @param mixed $id The identifier.
|
||||
* @param integer $lockMode
|
||||
* @param integer $lockVersion
|
||||
*
|
||||
* @return object The entity.
|
||||
*/
|
||||
public function find($id, $lockMode = LockMode::NONE, $lockVersion = null)
|
||||
{
|
||||
if ( ! is_array($id)) {
|
||||
$id = array($this->_class->identifier[0] => $id);
|
||||
}
|
||||
|
||||
$sortedId = array();
|
||||
|
||||
foreach ($this->_class->identifier as $identifier) {
|
||||
if ( ! isset($id[$identifier])) {
|
||||
throw ORMException::missingIdentifierField($this->_class->name, $identifier);
|
||||
}
|
||||
|
||||
$sortedId[$identifier] = $id[$identifier];
|
||||
}
|
||||
|
||||
// Check identity map first
|
||||
if (($entity = $this->_em->getUnitOfWork()->tryGetById($sortedId, $this->_class->rootEntityName)) !== false) {
|
||||
if ( ! ($entity instanceof $this->_class->name)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
switch ($lockMode) {
|
||||
case LockMode::OPTIMISTIC:
|
||||
$this->_em->lock($entity, $lockMode, $lockVersion);
|
||||
break;
|
||||
case LockMode::PESSIMISTIC_READ:
|
||||
case LockMode::PESSIMISTIC_WRITE:
|
||||
$persister = $this->_em->getUnitOfWork()->getEntityPersister($this->_entityName);
|
||||
$persister->refresh($sortedId, $entity, $lockMode);
|
||||
break;
|
||||
}
|
||||
|
||||
return $entity; // Hit!
|
||||
}
|
||||
|
||||
$persister = $this->_em->getUnitOfWork()->getEntityPersister($this->_entityName);
|
||||
|
||||
switch ($lockMode) {
|
||||
case LockMode::NONE:
|
||||
return $persister->load($sortedId);
|
||||
|
||||
case LockMode::OPTIMISTIC:
|
||||
if ( ! $this->_class->isVersioned) {
|
||||
throw OptimisticLockException::notVersioned($this->_entityName);
|
||||
}
|
||||
|
||||
$entity = $persister->load($sortedId);
|
||||
|
||||
$this->_em->getUnitOfWork()->lock($entity, $lockMode, $lockVersion);
|
||||
|
||||
return $entity;
|
||||
|
||||
default:
|
||||
if ( ! $this->_em->getConnection()->isTransactionActive()) {
|
||||
throw TransactionRequiredException::transactionRequired();
|
||||
}
|
||||
|
||||
return $persister->load($sortedId, null, null, array(), $lockMode);
|
||||
}
|
||||
return $this->_em->find($this->_entityName, $id, $lockMode, $lockVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -333,17 +272,5 @@ class EntityRepository implements ObjectRepository, Selectable
|
||||
|
||||
return new ArrayCollection($persister->loadCriteria($criteria));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return Builder object that helps with building criteria expressions.
|
||||
*
|
||||
* @return \Doctrine\Common\Collections\ExpressionBuilder
|
||||
*/
|
||||
public function expr()
|
||||
{
|
||||
if (self::$expressionBuilder === null) {
|
||||
self::$expressionBuilder = new ExpressionBuilder();
|
||||
}
|
||||
return self::$expressionBuilder;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -448,6 +448,7 @@ class ObjectHydrator extends AbstractHydrator
|
||||
$this->_resultPointers[$dqlAlias] = $element;
|
||||
} else {
|
||||
$this->_uow->setOriginalEntityProperty($oid, $relationField, null);
|
||||
$reflField->setValue($parentObject, null);
|
||||
}
|
||||
// else leave $reflFieldValue null for single-valued associations
|
||||
} else {
|
||||
|
||||
@@ -60,8 +60,12 @@ class AnnotationDriver extends AbstractAnnotationDriver
|
||||
|
||||
$classAnnotations = $this->reader->getClassAnnotations($class);
|
||||
|
||||
if ($classAnnotations && is_numeric(key($classAnnotations))) {
|
||||
foreach ($classAnnotations as $annot) {
|
||||
if ($classAnnotations) {
|
||||
foreach ($classAnnotations as $key => $annot) {
|
||||
if ( ! is_numeric($key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$classAnnotations[get_class($annot)] = $annot;
|
||||
}
|
||||
}
|
||||
@@ -456,8 +460,11 @@ class AnnotationDriver extends AbstractAnnotationDriver
|
||||
if ($method->isPublic() && $method->getDeclaringClass()->getName() == $class->name) {
|
||||
$annotations = $this->reader->getMethodAnnotations($method);
|
||||
|
||||
if ($annotations && is_numeric(key($annotations))) {
|
||||
foreach ($annotations as $annot) {
|
||||
if ($annotations) {
|
||||
foreach ($annotations as $key => $annot) {
|
||||
if ( ! is_numeric($key)) {
|
||||
continue;
|
||||
}
|
||||
$annotations[get_class($annot)] = $annot;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,8 +152,7 @@ class ORMException extends Exception
|
||||
|
||||
public static function invalidEntityRepository($className)
|
||||
{
|
||||
return new self("Invalid repository class '".$className."'. ".
|
||||
"it must be a Doctrine\\ORM\\EntityRepository.");
|
||||
return new self("Invalid repository class '".$className."'. It must be a Doctrine\Common\Persistence\ObjectRepository.");
|
||||
}
|
||||
|
||||
public static function missingIdentifierField($className, $fieldName)
|
||||
|
||||
@@ -43,7 +43,7 @@ class ORMInvalidArgumentException extends \InvalidArgumentException
|
||||
|
||||
static public function entityWithoutIdentity($className, $entity)
|
||||
{
|
||||
throw new self(
|
||||
return new self(
|
||||
"The given entity of type '" . $className . "' (".self::objToStr($entity).") has no identity/no " .
|
||||
"id values set. It cannot be added to the identity map."
|
||||
);
|
||||
@@ -70,30 +70,30 @@ class ORMInvalidArgumentException extends \InvalidArgumentException
|
||||
|
||||
static public function detachedEntityFoundThroughRelationship(array $assoc, $entry)
|
||||
{
|
||||
throw new self("A detached entity of type " . $assoc['targetEntity'] . " (" . self::objToStr($entry) . ") "
|
||||
return new self("A detached entity of type " . $assoc['targetEntity'] . " (" . self::objToStr($entry) . ") "
|
||||
. " was found through the relationship '" . $assoc['sourceEntity'] . "#" . $assoc['fieldName'] . "' "
|
||||
. "during cascading a persist operation.");
|
||||
}
|
||||
|
||||
static public function entityNotManaged($entity)
|
||||
{
|
||||
throw new self("Entity " . self::objToStr($entity) . " is not managed. An entity is managed if its fetched " .
|
||||
return new self("Entity " . self::objToStr($entity) . " is not managed. An entity is managed if its fetched " .
|
||||
"from the database or registered as new through EntityManager#persist");
|
||||
}
|
||||
|
||||
static public function entityHasNoIdentity($entity, $operation)
|
||||
{
|
||||
throw new self("Entity has no identity, therefore " . $operation ." cannot be performed. " . self::objToStr($entity));
|
||||
return new self("Entity has no identity, therefore " . $operation ." cannot be performed. " . self::objToStr($entity));
|
||||
}
|
||||
|
||||
static public function entityIsRemoved($entity, $operation)
|
||||
{
|
||||
throw new self("Entity is removed, therefore " . $operation ." cannot be performed. " . self::objToStr($entity));
|
||||
return new self("Entity is removed, therefore " . $operation ." cannot be performed. " . self::objToStr($entity));
|
||||
}
|
||||
|
||||
static public function detachedEntityCannot($entity, $operation)
|
||||
{
|
||||
throw new self("A detached entity was found during " . $operation . " " . self::objToStr($entity));
|
||||
return new self("A detached entity was found during " . $operation . " " . self::objToStr($entity));
|
||||
}
|
||||
|
||||
public static function invalidObject($context, $given, $parameterIndex = 1)
|
||||
|
||||
@@ -46,11 +46,6 @@ use Closure;
|
||||
*/
|
||||
final class PersistentCollection implements Collection, Selectable
|
||||
{
|
||||
/**
|
||||
* @var Doctrine\Common\Collections\ExpressionBuilder
|
||||
*/
|
||||
static private $expressionBuilder;
|
||||
|
||||
/**
|
||||
* A snapshot of the collection at the moment it was fetched from the database.
|
||||
* This is used to create a diff of the collection at commit time.
|
||||
@@ -294,7 +289,7 @@ final class PersistentCollection implements Collection, Selectable
|
||||
/**
|
||||
* INTERNAL: Gets the association mapping of the collection.
|
||||
*
|
||||
* @return \Doctrine\ORM\Mapping\AssociationMapping
|
||||
* @return array
|
||||
*/
|
||||
public function getMapping()
|
||||
{
|
||||
@@ -820,7 +815,7 @@ final class PersistentCollection implements Collection, Selectable
|
||||
$targetClass = $this->em->getClassMetadata(get_class($this->owner));
|
||||
|
||||
$id = $targetClass->getSingleIdReflectionProperty()->getValue($this->owner);
|
||||
$builder = $this->expr();
|
||||
$builder = Criteria::expr();
|
||||
$ownerExpression = $builder->eq($this->backRefFieldName, $id);
|
||||
$expression = $criteria->getWhereExpression();
|
||||
$expression = $expression ? $builder->andX($expression, $ownerExpression) : $ownerExpression;
|
||||
@@ -831,19 +826,5 @@ final class PersistentCollection implements Collection, Selectable
|
||||
|
||||
return new ArrayCollection($persister->loadCriteria($criteria));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return Builder object that helps with building criteria expressions.
|
||||
*
|
||||
* @return \Doctrine\Common\Collections\ExpressionBuilder
|
||||
*/
|
||||
public function expr()
|
||||
{
|
||||
if (self::$expressionBuilder === null) {
|
||||
self::$expressionBuilder = new ExpressionBuilder();
|
||||
}
|
||||
|
||||
return self::$expressionBuilder;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
||||
}
|
||||
|
||||
// Composite identifier
|
||||
$sourceClass = $this->_em->getClassMetadata(get_class($mapping->getOwner()));
|
||||
$sourceClass = $this->_em->getClassMetadata(get_class($coll->getOwner()));
|
||||
|
||||
foreach ($mapping['relationToSourceKeyColumns'] as $srcColumn) {
|
||||
$params[] = $identifier[$sourceClass->fieldNames[$srcColumn]];
|
||||
|
||||
@@ -21,7 +21,6 @@ namespace Doctrine\ORM\Proxy;
|
||||
|
||||
use Doctrine\ORM\EntityManager,
|
||||
Doctrine\ORM\Mapping\ClassMetadata,
|
||||
Doctrine\ORM\Mapping\AssociationMapping,
|
||||
Doctrine\Common\Util\ClassUtils;
|
||||
|
||||
/**
|
||||
|
||||
@@ -54,7 +54,7 @@ class Parameter
|
||||
{
|
||||
$this->name = trim($name, ':');
|
||||
|
||||
$this->setValue($value);
|
||||
$this->setValue($value, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,4 +98,4 @@ class Parameter
|
||||
$this->value = $value;
|
||||
$this->type = $type ?: ParameterTypeInferer::inferType($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
namespace Doctrine\ORM\Query;
|
||||
|
||||
use Doctrine\DBAL\Connection,
|
||||
Doctrine\DBAL\Types\Type;
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
|
||||
/**
|
||||
* Provides an enclosed support for parameter infering.
|
||||
@@ -46,27 +46,20 @@ class ParameterTypeInferer
|
||||
*/
|
||||
public static function inferType($value)
|
||||
{
|
||||
switch (true) {
|
||||
case is_integer($value):
|
||||
return Type::INTEGER;
|
||||
if (is_integer($value)) {
|
||||
return Type::INTEGER;
|
||||
}
|
||||
|
||||
case ($value instanceof \DateTime):
|
||||
return Type::DATETIME;
|
||||
if ($value instanceof \DateTime) {
|
||||
return Type::DATETIME;
|
||||
}
|
||||
|
||||
case is_array($value):
|
||||
$key = key($value);
|
||||
|
||||
if (is_integer($value[$key])) {
|
||||
return Connection::PARAM_INT_ARRAY;
|
||||
}
|
||||
|
||||
return Connection::PARAM_STR_ARRAY;
|
||||
|
||||
default:
|
||||
// Do nothing
|
||||
break;
|
||||
if (is_array($value)) {
|
||||
return is_integer(current($value))
|
||||
? Connection::PARAM_INT_ARRAY
|
||||
: Connection::PARAM_STR_ARRAY;
|
||||
}
|
||||
|
||||
return \PDO::PARAM_STR;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,7 +96,7 @@ class QueryException extends \Doctrine\ORM\ORMException
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Doctrine\ORM\Mapping\AssociationMapping $assoc
|
||||
* @param array $assoc
|
||||
*/
|
||||
public static function iterateWithFetchJoinCollectionNotAllowed($assoc)
|
||||
{
|
||||
|
||||
@@ -429,7 +429,7 @@ class QueryBuilder
|
||||
*
|
||||
* @param mixed $key The key (index or name) of the bound parameter.
|
||||
*
|
||||
* @return mixed The value of the bound parameter.
|
||||
* @return Query\Parameter|null The value of the bound parameter.
|
||||
*/
|
||||
public function getParameter($key)
|
||||
{
|
||||
@@ -1169,5 +1169,13 @@ class QueryBuilder
|
||||
$this->_dqlParts[$part] = clone $elements;
|
||||
}
|
||||
}
|
||||
|
||||
$parameters = array();
|
||||
|
||||
foreach ($this->parameters as $parameter) {
|
||||
$parameters[] = clone $parameter;
|
||||
}
|
||||
|
||||
$this->parameters = new ArrayCollection($parameters);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ use Symfony\Component\Console\Input\InputArgument,
|
||||
/**
|
||||
* Command to clear the metadata cache of the various cache drivers.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.0
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
@@ -52,20 +52,19 @@ class MetadataCommand extends Console\Command\Command
|
||||
)
|
||||
));
|
||||
|
||||
$fullName = $this->getName();
|
||||
$this->setHelp(<<<EOT
|
||||
The <info>$fullName</info> command is meant to clear the metadata cache of associated Entity Manager.
|
||||
The <info>%command.name%</info> command is meant to clear the metadata cache of associated Entity Manager.
|
||||
It is possible to invalidate all cache entries at once - called delete -, or flushes the cache provider
|
||||
instance completely.
|
||||
|
||||
The execution type differ on how you execute the command.
|
||||
If you want to invalidate the entries (and not delete from cache instance), this command would do the work:
|
||||
|
||||
<info>$fullName</info>
|
||||
<info>%command.name%</info>
|
||||
|
||||
Alternatively, if you want to flush the cache provider using this command:
|
||||
|
||||
<info>$fullName --flush</info>
|
||||
<info>%command.name% --flush</info>
|
||||
|
||||
Finally, be aware that if <info>--flush</info> option is passed, not all cache providers are able to flush entries,
|
||||
because of a limitation of its execution nature.
|
||||
|
||||
@@ -27,7 +27,7 @@ use Symfony\Component\Console\Input\InputArgument,
|
||||
/**
|
||||
* Command to clear the query cache of the various cache drivers.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.0
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
@@ -52,20 +52,19 @@ class QueryCommand extends Console\Command\Command
|
||||
)
|
||||
));
|
||||
|
||||
$fullName = $this->getName();
|
||||
$this->setHelp(<<<EOT
|
||||
The <info>$fullName</info> command is meant to clear the query cache of associated Entity Manager.
|
||||
The <info>%command.name%</info> command is meant to clear the query cache of associated Entity Manager.
|
||||
It is possible to invalidate all cache entries at once - called delete -, or flushes the cache provider
|
||||
instance completely.
|
||||
|
||||
The execution type differ on how you execute the command.
|
||||
If you want to invalidate the entries (and not delete from cache instance), this command would do the work:
|
||||
|
||||
<info>$fullName</info>
|
||||
<info>%command.name%</info>
|
||||
|
||||
Alternatively, if you want to flush the cache provider using this command:
|
||||
|
||||
<info>$fullName --flush</info>
|
||||
<info>%command.name% --flush</info>
|
||||
|
||||
Finally, be aware that if <info>--flush</info> option is passed, not all cache providers are able to flush entries,
|
||||
because of a limitation of its execution nature.
|
||||
|
||||
@@ -27,7 +27,7 @@ use Symfony\Component\Console\Input\InputArgument,
|
||||
/**
|
||||
* Command to clear the result cache of the various cache drivers.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.0
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
@@ -52,20 +52,19 @@ class ResultCommand extends Console\Command\Command
|
||||
)
|
||||
));
|
||||
|
||||
$fullName = $this->getName();
|
||||
$this->setHelp(<<<EOT
|
||||
The <info>$fullName</info> command is meant to clear the result cache of associated Entity Manager.
|
||||
The <info>%command.name%</info> command is meant to clear the result cache of associated Entity Manager.
|
||||
It is possible to invalidate all cache entries at once - called delete -, or flushes the cache provider
|
||||
instance completely.
|
||||
|
||||
The execution type differ on how you execute the command.
|
||||
If you want to invalidate the entries (and not delete from cache instance), this command would do the work:
|
||||
|
||||
<info>$fullName</info>
|
||||
<info>%command.name%</info>
|
||||
|
||||
Alternatively, if you want to flush the cache provider using this command:
|
||||
|
||||
<info>$fullName --flush</info>
|
||||
<info>%command.name% --flush</info>
|
||||
|
||||
Finally, be aware that if <info>--flush</info> option is passed, not all cache providers are able to flush entries,
|
||||
because of a limitation of its execution nature.
|
||||
|
||||
@@ -27,7 +27,7 @@ use Symfony\Component\Console\Command\Command;
|
||||
/**
|
||||
* Show information about mapped entities
|
||||
*
|
||||
*
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.1
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
@@ -40,7 +40,7 @@ class InfoCommand extends Command
|
||||
->setName('orm:info')
|
||||
->setDescription('Show basic information about all mapped entities')
|
||||
->setHelp(<<<EOT
|
||||
The <info>doctrine:mapping:info</info> shows basic information about which
|
||||
The <info>%command.name%</info> shows basic information about which
|
||||
entities exist and possibly if their mapping information contains errors or
|
||||
not.
|
||||
EOT
|
||||
|
||||
@@ -29,7 +29,7 @@ use Symfony\Component\Console\Input\InputArgument,
|
||||
* Command to generate the SQL needed to update the database schema to match
|
||||
* the current mapping information.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.0
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
@@ -68,20 +68,19 @@ class UpdateCommand extends AbstractCommand
|
||||
),
|
||||
));
|
||||
|
||||
$fullName = $this->getName();
|
||||
$this->setHelp(<<<EOT
|
||||
The <info>$fullName</info> command generates the SQL needed to
|
||||
The <info>%command.name%</info> command generates the SQL needed to
|
||||
synchronize the database schema with the current mapping metadata of the
|
||||
default entity manager.
|
||||
|
||||
For example, if you add metadata for a new column to an entity, this command
|
||||
would generate and output the SQL needed to add the new column to the database:
|
||||
|
||||
<info>$fullName --dump-sql</info>
|
||||
<info>%command.name% --dump-sql</info>
|
||||
|
||||
Alternatively, you can execute the generated queries:
|
||||
|
||||
<info>$fullName --force</info>
|
||||
<info>%command.name% --force</info>
|
||||
|
||||
Finally, be aware that if the <info>--complete</info> option is passed, this
|
||||
task will drop all database assets (e.g. tables, etc) that are *not* described
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
namespace Doctrine\ORM\Tools;
|
||||
|
||||
use Doctrine\ORM\Mapping\ClassMetadataInfo,
|
||||
Doctrine\ORM\Mapping\AssociationMapping,
|
||||
Doctrine\Common\Util\Inflector,
|
||||
Doctrine\DBAL\Types\Type;
|
||||
|
||||
@@ -154,6 +153,8 @@ class EntityGenerator
|
||||
Type::TEXT => 'string',
|
||||
Type::BLOB => 'string',
|
||||
Type::DECIMAL => 'float',
|
||||
Type::JSON_ARRAY => 'array',
|
||||
Type::SIMPLE_ARRAY => 'array',
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
namespace Doctrine\ORM\Tools\Export\Driver;
|
||||
|
||||
use Doctrine\ORM\Mapping\ClassMetadataInfo,
|
||||
Doctrine\ORM\Mapping\AssociationMapping,
|
||||
Doctrine\ORM\Tools\EntityGenerator;
|
||||
|
||||
/**
|
||||
|
||||
@@ -174,16 +174,18 @@ class Paginator implements \Countable, \IteratorAggregate
|
||||
|
||||
$whereInQuery = $this->cloneQuery($this->query);
|
||||
// don't do this for an empty id array
|
||||
if (count($ids) > 0) {
|
||||
$namespace = WhereInWalker::PAGINATOR_ID_ALIAS;
|
||||
if (count($ids) == 0) {
|
||||
return new \ArrayIterator(array());
|
||||
}
|
||||
|
||||
$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);
|
||||
}
|
||||
$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);
|
||||
}
|
||||
|
||||
$result = $whereInQuery->getResult($this->query->getHydrationMode());
|
||||
|
||||
@@ -36,7 +36,7 @@ class Version
|
||||
/**
|
||||
* Current Doctrine Version
|
||||
*/
|
||||
const VERSION = '2.3.0-BETA1';
|
||||
const VERSION = '2.3.0-RC2';
|
||||
|
||||
/**
|
||||
* Compares a Doctrine version with the current one.
|
||||
|
||||
Vendored
+1
-1
Submodule lib/vendor/doctrine-common updated: f7cdf27f04...0f7ba7fa71
Vendored
+1
-1
Submodule lib/vendor/doctrine-dbal updated: 79e894b449...a2da6c6f8a
@@ -10,7 +10,7 @@ namespace Doctrine\Tests\Mocks;
|
||||
class StatementMock implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
|
||||
{
|
||||
public function bindValue($param, $value, $type = null){}
|
||||
public function bindParam($column, &$variable, $type = null){}
|
||||
public function bindParam($column, &$variable, $type = null, $length = null){}
|
||||
public function errorCode(){}
|
||||
public function errorInfo(){}
|
||||
public function execute($params = null){}
|
||||
|
||||
@@ -30,12 +30,25 @@ class NavPointOfInterest
|
||||
*/
|
||||
private $country;
|
||||
|
||||
/**
|
||||
* @ManyToMany(targetEntity="NavUser", cascade={"persist"})
|
||||
* @JoinTable(name="navigation_pois_visitors",
|
||||
* inverseJoinColumns={@JoinColumn(name="user_id", referencedColumnName="id")},
|
||||
* joinColumns={
|
||||
* @JoinColumn(name="poi_long", referencedColumnName="nav_long"),
|
||||
* @JoinColumn(name="poi_lat", referencedColumnName="nav_lat")
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
private $visitors;
|
||||
|
||||
public function __construct($lat, $long, $name, $country)
|
||||
{
|
||||
$this->lat = $lat;
|
||||
$this->long = $long;
|
||||
$this->name = $name;
|
||||
$this->country = $country;
|
||||
$this->visitors = new \Doctrine\Common\Collections\ArrayCollection;
|
||||
}
|
||||
|
||||
public function getLong() {
|
||||
@@ -53,4 +66,14 @@ class NavPointOfInterest
|
||||
public function getCountry() {
|
||||
return $this->country;
|
||||
}
|
||||
|
||||
public function addVisitor(NavUser $user)
|
||||
{
|
||||
$this->visitors[] = $user;
|
||||
}
|
||||
|
||||
public function getVisitors()
|
||||
{
|
||||
return $this->visitors;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\Navigation;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="navigation_users")
|
||||
*/
|
||||
class NavUser
|
||||
{
|
||||
/**
|
||||
* @Id
|
||||
* @Column(type="integer")
|
||||
* @generatedValue
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @column(type="string")
|
||||
*/
|
||||
private $name;
|
||||
|
||||
public function __construct($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,6 +206,21 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertSame(__CLASS__, $this->configuration->getCustomHydrationMode('HydrationModeName'));
|
||||
}
|
||||
|
||||
public function testSetCustomHydrationModes()
|
||||
{
|
||||
$this->configuration->addCustomHydrationMode('HydrationModeName', __CLASS__);
|
||||
$this->assertSame(__CLASS__, $this->configuration->getCustomHydrationMode('HydrationModeName'));
|
||||
|
||||
$this->configuration->setCustomHydrationModes(
|
||||
array(
|
||||
'AnotherHydrationModeName' => __CLASS__
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertNull($this->configuration->getCustomHydrationMode('HydrationModeName'));
|
||||
$this->assertSame(__CLASS__, $this->configuration->getCustomHydrationMode('AnotherHydrationModeName'));
|
||||
}
|
||||
|
||||
public function testSetGetClassMetadataFactoryName()
|
||||
{
|
||||
$this->assertSame('Doctrine\ORM\Mapping\ClassMetadataFactory', $this->configuration->getClassMetadataFactoryName());
|
||||
|
||||
@@ -484,13 +484,13 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
|
||||
$repository = $this->_em->getRepository("Doctrine\Tests\Models\Company\CompanyEmployee");
|
||||
$users = $repository->matching(new Criteria(
|
||||
$repository->expr()->eq('department', 'IT')
|
||||
Criteria::expr()->eq('department', 'IT')
|
||||
));
|
||||
$this->assertEquals(1, count($users));
|
||||
|
||||
$repository = $this->_em->getRepository("Doctrine\Tests\Models\Company\CompanyManager");
|
||||
$users = $repository->matching(new Criteria(
|
||||
$repository->expr()->eq('department', 'IT')
|
||||
Criteria::expr()->eq('department', 'IT')
|
||||
));
|
||||
$this->assertEquals(1, count($users));
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ use Doctrine\Tests\Models\Navigation\NavCountry;
|
||||
use Doctrine\Tests\Models\Navigation\NavPointOfInterest;
|
||||
use Doctrine\Tests\Models\Navigation\NavTour;
|
||||
use Doctrine\Tests\Models\Navigation\NavPhotos;
|
||||
use Doctrine\Tests\Models\Navigation\NavUser;
|
||||
|
||||
require_once __DIR__ . '/../../TestInit.php';
|
||||
|
||||
@@ -118,4 +119,26 @@ class CompositePrimaryKeyTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$this->setExpectedException('Doctrine\ORM\ORMException', 'The identifier long is missing for a query of Doctrine\Tests\Models\Navigation\NavPointOfInterest');
|
||||
$poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', array('key1' => 100));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-1939
|
||||
*/
|
||||
public function testDeleteCompositePersistentCollection()
|
||||
{
|
||||
$this->putGermanysBrandenburderTor();
|
||||
|
||||
$poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', array('lat' => 100, 'long' => 200));
|
||||
$poi->addVisitor(new NavUser("test1"));
|
||||
$poi->addVisitor(new NavUser("test2"));
|
||||
|
||||
$this->_em->flush();
|
||||
|
||||
$poi->getVisitors()->clear();
|
||||
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
|
||||
$poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', array('lat' => 100, 'long' => 200));
|
||||
$this->assertEquals(0, count($poi->getVisitors()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -528,7 +528,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
/**
|
||||
* @group DDC-753
|
||||
* @expectedException Doctrine\ORM\ORMException
|
||||
* @expectedExceptionMessage Invalid repository class 'Doctrine\Tests\Models\DDC753\DDC753InvalidRepository'. it must be a Doctrine\ORM\EntityRepository.
|
||||
* @expectedExceptionMessage Invalid repository class 'Doctrine\Tests\Models\DDC753\DDC753InvalidRepository'. It must be a Doctrine\Common\Persistence\ObjectRepository.
|
||||
*/
|
||||
public function testSetDefaultRepositoryInvalidClassError()
|
||||
{
|
||||
@@ -582,7 +582,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
|
||||
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
|
||||
$users = $repository->matching(new Criteria(
|
||||
$repository->expr()->eq('username', 'beberlei')
|
||||
Criteria::expr()->eq('username', 'beberlei')
|
||||
));
|
||||
|
||||
$this->assertEquals(1, count($users));
|
||||
@@ -597,7 +597,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
|
||||
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
|
||||
$users = $repository->matching(new Criteria(
|
||||
$repository->expr()->neq('username', 'beberlei')
|
||||
Criteria::expr()->neq('username', 'beberlei')
|
||||
));
|
||||
|
||||
$this->assertEquals(3, count($users));
|
||||
@@ -612,7 +612,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
|
||||
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
|
||||
$users = $repository->matching(new Criteria(
|
||||
$repository->expr()->in('username', array('beberlei', 'gblanco'))
|
||||
Criteria::expr()->in('username', array('beberlei', 'gblanco'))
|
||||
));
|
||||
|
||||
$this->assertEquals(2, count($users));
|
||||
@@ -627,7 +627,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
|
||||
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
|
||||
$users = $repository->matching(new Criteria(
|
||||
$repository->expr()->notIn('username', array('beberlei', 'gblanco', 'asm89'))
|
||||
Criteria::expr()->notIn('username', array('beberlei', 'gblanco', 'asm89'))
|
||||
));
|
||||
|
||||
$this->assertEquals(1, count($users));
|
||||
@@ -642,7 +642,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
|
||||
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
|
||||
$users = $repository->matching(new Criteria(
|
||||
$repository->expr()->lt('id', $firstUserId + 1)
|
||||
Criteria::expr()->lt('id', $firstUserId + 1)
|
||||
));
|
||||
|
||||
$this->assertEquals(1, count($users));
|
||||
@@ -657,7 +657,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
|
||||
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
|
||||
$users = $repository->matching(new Criteria(
|
||||
$repository->expr()->lte('id', $firstUserId + 1)
|
||||
Criteria::expr()->lte('id', $firstUserId + 1)
|
||||
));
|
||||
|
||||
$this->assertEquals(2, count($users));
|
||||
@@ -672,7 +672,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
|
||||
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
|
||||
$users = $repository->matching(new Criteria(
|
||||
$repository->expr()->gt('id', $firstUserId)
|
||||
Criteria::expr()->gt('id', $firstUserId)
|
||||
));
|
||||
|
||||
$this->assertEquals(3, count($users));
|
||||
@@ -687,7 +687,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
|
||||
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
|
||||
$users = $repository->matching(new Criteria(
|
||||
$repository->expr()->gte('id', $firstUserId)
|
||||
Criteria::expr()->gte('id', $firstUserId)
|
||||
));
|
||||
|
||||
$this->assertEquals(4, count($users));
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Doctrine\Tests\ORM\Functional;
|
||||
|
||||
use Doctrine\Tests\Models\ECommerce\ECommerceProduct;
|
||||
use Doctrine\Tests\Models\ECommerce\ECommerceFeature;
|
||||
use Doctrine\ORM\Mapping\AssociationMapping;
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
|
||||
require_once __DIR__ . '/../../TestInit.php';
|
||||
|
||||
@@ -161,14 +161,14 @@ class OneToManyBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
|
||||
$product = $this->_em->find('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $this->product->getId());
|
||||
$features = $product->getFeatures();
|
||||
|
||||
$results = $features->matching(new \Doctrine\Common\Collections\Criteria(
|
||||
$features->expr()->eq('description', 'Model writing tutorial')
|
||||
$results = $features->matching(new Criteria(
|
||||
Criteria::expr()->eq('description', 'Model writing tutorial')
|
||||
));
|
||||
|
||||
$this->assertInstanceOf('Doctrine\Common\Collections\Collection', $results);
|
||||
$this->assertEquals(1, count($results));
|
||||
|
||||
$results = $features->matching(new \Doctrine\Common\Collections\Criteria());
|
||||
$results = $features->matching(new Criteria());
|
||||
|
||||
$this->assertInstanceOf('Doctrine\Common\Collections\Collection', $results);
|
||||
$this->assertEquals(2, count($results));
|
||||
|
||||
@@ -21,6 +21,7 @@ class OneToOneEagerLoadingTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\TrainDriver'),
|
||||
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\TrainOwner'),
|
||||
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Waggon'),
|
||||
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\TrainOrder'),
|
||||
));
|
||||
} catch(\Exception $e) {}
|
||||
}
|
||||
@@ -181,6 +182,24 @@ class OneToOneEagerLoadingTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$this->_sqlLoggerStack->queries[$this->_sqlLoggerStack->currentQuery]['sql']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-1946
|
||||
*/
|
||||
public function testEagerLoadingDoesNotBreakRefresh()
|
||||
{
|
||||
$train = new Train(new TrainOwner('Johannes'));
|
||||
$order = new TrainOrder($train);
|
||||
$this->_em->persist($train);
|
||||
$this->_em->persist($order);
|
||||
$this->_em->flush();
|
||||
|
||||
$this->_em->getConnection()->exec("UPDATE TrainOrder SET train_id = NULL");
|
||||
|
||||
$this->assertSame($train, $order->train);
|
||||
$this->_em->refresh($order);
|
||||
$this->assertTrue($order->train === null, "Train reference was not refreshed to NULL.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -305,3 +324,20 @@ class Waggon
|
||||
$this->train = $train;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
*/
|
||||
class TrainOrder
|
||||
{
|
||||
/** @id @generatedValue @column(type="integer") */
|
||||
public $id;
|
||||
|
||||
/** @OneToOne(targetEntity = "Train", fetch = "EAGER") */
|
||||
public $train;
|
||||
|
||||
public function __construct(Train $train)
|
||||
{
|
||||
$this->train = $train;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,13 +343,13 @@ class SingleTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
|
||||
$repository = $this->_em->getRepository("Doctrine\Tests\Models\Company\CompanyContract");
|
||||
$contracts = $repository->matching(new Criteria(
|
||||
$repository->expr()->eq('salesPerson', $this->salesPerson->getId())
|
||||
Criteria::expr()->eq('salesPerson', $this->salesPerson->getId())
|
||||
));
|
||||
$this->assertEquals(3, count($contracts));
|
||||
|
||||
$repository = $this->_em->getRepository("Doctrine\Tests\Models\Company\CompanyFixContract");
|
||||
$contracts = $repository->matching(new Criteria(
|
||||
$repository->expr()->eq('salesPerson', $this->salesPerson->getId())
|
||||
Criteria::expr()->eq('salesPerson', $this->salesPerson->getId())
|
||||
));
|
||||
$this->assertEquals(1, count($contracts));
|
||||
}
|
||||
|
||||
@@ -5,8 +5,6 @@ namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||
use Doctrine\Tests\Models\Quote\Group;
|
||||
use Doctrine\Tests\Models\Quote\User;
|
||||
|
||||
require_once __DIR__ . '/../../../TestInit.php';
|
||||
|
||||
/**
|
||||
* @group DDC-1845
|
||||
* @group DDC-1885
|
||||
@@ -170,4 +168,4 @@ class DDC1885Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\Quote\Group', $user->getGroups()->get(0));
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\Quote\Group', $user->getGroups()->get(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||
|
||||
use Doctrine\Tests\Models\CMS\CmsUser;
|
||||
use Doctrine\Tests\Models\CMS\CmsGroup;
|
||||
use Doctrine\ORM\Tools\Pagination\Paginator;
|
||||
|
||||
/**
|
||||
* @group DDC-1918
|
||||
*/
|
||||
class DDC1918Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
$this->useModelSet('cms');
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function testLastPageCorrect()
|
||||
{
|
||||
$groups = array();
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$group = new CmsGroup();
|
||||
$group->name = "test";
|
||||
$this->_em->persist($group);
|
||||
|
||||
$groups[] = $group;
|
||||
}
|
||||
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
$user = new CmsUser();
|
||||
$user->username = "user$i";
|
||||
$user->name = "user$i";
|
||||
$user->status = "active";
|
||||
$user->groups = $groups;
|
||||
|
||||
$this->_em->persist($user);
|
||||
}
|
||||
|
||||
$this->_em->flush();
|
||||
|
||||
$query = $this->_em->createQuery('SELECT u, g FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g');
|
||||
$query->setFirstResult(6);
|
||||
$query->setMaxResults(3);
|
||||
|
||||
$paginator = new Paginator($query, true);
|
||||
$this->assertEquals(3, count(iterator_to_array($paginator)));
|
||||
|
||||
$query->setFirstResult(8);
|
||||
$query->setMaxResults(3);
|
||||
|
||||
$paginator = new Paginator($query, true);
|
||||
$this->assertEquals(2, count(iterator_to_array($paginator)));
|
||||
|
||||
$query->setFirstResult(10);
|
||||
$query->setMaxResults(3);
|
||||
|
||||
$paginator = new Paginator($query, true);
|
||||
$this->assertEquals(0, count(iterator_to_array($paginator)));
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,9 @@ use Doctrine\ORM\Query;
|
||||
|
||||
require_once __DIR__ . '/../../../TestInit.php';
|
||||
|
||||
/**
|
||||
* @group DDC-371
|
||||
*/
|
||||
class DDC371Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
{
|
||||
protected function setUp()
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
namespace Doctrine\Tests\ORM\Query;
|
||||
|
||||
use Doctrine\ORM\Query\ParameterTypeInferer;
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use PDO;
|
||||
|
||||
require_once __DIR__ . '/../../TestInit.php';
|
||||
|
||||
class ParameterTypeInfererTest extends \Doctrine\Tests\OrmTestCase
|
||||
{
|
||||
|
||||
public function providerParameterTypeInferer()
|
||||
{
|
||||
return array(
|
||||
array(1, Type::INTEGER),
|
||||
array("bar", PDO::PARAM_STR),
|
||||
array("1", PDO::PARAM_STR),
|
||||
array(new \DateTime, Type::DATETIME),
|
||||
array(array(2), Connection::PARAM_INT_ARRAY),
|
||||
array(array("foo"), Connection::PARAM_STR_ARRAY),
|
||||
array(array("1","2"), Connection::PARAM_STR_ARRAY),
|
||||
array(array(), Connection::PARAM_STR_ARRAY),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerParameterTypeInferer
|
||||
*/
|
||||
|
||||
public function testParameterTypeInferer($value, $expected)
|
||||
{
|
||||
$this->assertEquals($expected, ParameterTypeInferer::inferType($value));
|
||||
}
|
||||
}
|
||||
@@ -664,6 +664,23 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase
|
||||
$this->assertEquals(2, $expr->count(), "Modifying the second query should affect the first one.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-1933
|
||||
*/
|
||||
public function testParametersAreCloned()
|
||||
{
|
||||
$originalQb = new QueryBuilder($this->_em);
|
||||
|
||||
$originalQb->setParameter('parameter1', 'value1');
|
||||
|
||||
$copy = clone $originalQb;
|
||||
$copy->setParameter('parameter2', 'value2');
|
||||
|
||||
$this->assertCount(1, $originalQb->getParameters());
|
||||
$this->assertSame('value1', $copy->getParameter('parameter1')->getValue());
|
||||
$this->assertSame('value2', $copy->getParameter('parameter2')->getValue());
|
||||
}
|
||||
|
||||
public function testGetRootAlias()
|
||||
{
|
||||
$qb = $this->_em->createQueryBuilder()
|
||||
|
||||
@@ -88,6 +88,7 @@ abstract class OrmFunctionalTestCase extends OrmTestCase
|
||||
'Doctrine\Tests\Models\Routing\RoutingRouteBooking',
|
||||
),
|
||||
'navigation' => array(
|
||||
'Doctrine\Tests\Models\Navigation\NavUser',
|
||||
'Doctrine\Tests\Models\Navigation\NavCountry',
|
||||
'Doctrine\Tests\Models\Navigation\NavPhotos',
|
||||
'Doctrine\Tests\Models\Navigation\NavTour',
|
||||
|
||||
@@ -30,7 +30,7 @@ $connectionOptions = array(
|
||||
|
||||
$em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);
|
||||
|
||||
$helpers = array(
|
||||
$helpers = new Symfony\Component\Console\Helper\HelperSet(array(
|
||||
'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
|
||||
'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)
|
||||
);
|
||||
));
|
||||
Reference in New Issue
Block a user