Compare commits

...

76 Commits

Author SHA1 Message Date
Benjamin Eberlei 9308afc9a5 Release 2.3.0-RC2 2012-08-29 16:36:26 +02:00
Benjamin Eberlei 1a81444b04 Bump dev version to 2.3.0 2012-08-29 16:35:51 +02:00
Benjamin Eberlei d181fbc98d Release 2.3.0-RC2 2012-08-29 16:35:51 +02:00
Benjamin Eberlei 114e233d87 Revert "Merge remote-tracking branch 'origin/master' into 2.3"
This reverts commit 131d3003a0, reversing
changes made to 9d909cd583.
2012-08-29 15:50:08 +02:00
Benjamin Eberlei bdb36a71c5 Merge branch 'DDC-1918' into 2.3 2012-08-29 15:15:35 +02:00
Benjamin Eberlei 8c1d64372c Merge remote-tracking branch 'origin/2.3' into 2.3 2012-08-29 15:15:27 +02:00
Benjamin Eberlei f4ba58358c [DDC-1918] Fix weird results at the end of paginator when using fetch joins 2012-08-29 15:14:40 +02:00
Benjamin Eberlei 131d3003a0 Merge remote-tracking branch 'origin/master' into 2.3 2012-08-29 14:01:18 +02:00
Benjamin Eberlei 48e94343fd Merge pull request #427 from chEbba/return-exception
Fix ORMInvalidArgumentException factory methods with return instead of throw
2012-08-29 04:57:32 -07:00
FabioBatSilva 9d909cd583 Fix DDC-1977 2012-08-29 13:40:18 +02:00
Kirill chEbba Chebunin 3aaa90e1a8 Fix ORMInvalidArgumentException factory methods with return instead of throw 2012-08-19 22:58:40 +04:00
Guilherme Blanco ece6a005bc Merge pull request #425 from FabioBatSilva/DDC-1977
Fix DDC-1977
2012-08-15 15:29:26 -07:00
FabioBatSilva 641af15280 Fix DDC-1977 2012-08-15 22:57:21 +02:00
Alexander 971865f271 Merge branch 'config' into 2.3 2012-08-14 22:51:23 +02:00
Alexander af08f05164 Fix setCustomHydrationModes + added test 2012-08-14 22:47:35 +02:00
Martin Meredith 2e6b50bb53 Create the setCustomHydrationMode function
This allows multiple hydrators to be set at once, and also allows for
the customHydrationMode options to be set via DoctrineORMModule
2012-08-14 22:47:35 +02:00
Alexander 185b4e0c41 Fix setCustomHydrationModes + added test 2012-08-14 22:43:32 +02:00
Alexander 5c585b4c02 Merge branch 'config' 2012-08-14 22:33:36 +02:00
Martin Meredith 787a208708 Create the setCustomHydrationMode function
This allows multiple hydrators to be set at once, and also allows for
the customHydrationMode options to be set via DoctrineORMModule
2012-08-14 22:33:25 +02:00
Guilherme Blanco f8a582d454 Merge pull request #391 from FabioBatSilva/ns-class
Give FQCN to NamingStrategy#propertyToColumnName
2012-08-12 15:50:20 -07:00
Guilherme Blanco 72ce9a7f37 Merge pull request #417 from jonathaningram/patch-1
Remove unused use statement
2012-08-01 23:38:56 -07:00
Jonathan Ingram 04de52d4c9 Remove unused use statement 2012-08-02 15:33:09 +10:00
Benjamin Eberlei 17862d9a2a Merge branch 'CriteriaExpressionBuilder' into 2.3 2012-08-01 21:40:25 +02:00
Benjamin Eberlei c99c7b6694 Update EntityRepository and PersistentCollection to new Criteria#expr() method instead of having to implement themselves. 2012-08-01 21:39:39 +02:00
Benjamin Eberlei 104a76a6b1 Update EntityRepository and PersistentCollection to new Criteria#expr() method instead of having to implement themselves. 2012-08-01 21:37:22 +02:00
Michael Moravec 79a04b295f [DDC-1961] Fixed parameter type support in Parameter 2012-07-31 21:01:21 +02:00
Guilherme Blanco 3f2ddc60d4 Merge pull request #416 from Majkl578/DDC-1961
[DDC-1961] Fixed parameter type support in Parameter
2012-07-31 07:34:24 -07:00
Michael Moravec 3b3d762277 [DDC-1961] Fixed parameter type support in Parameter 2012-07-31 16:30:27 +02:00
Benjamin Eberlei 992b51eba7 Bump dev version to 2.3.0 2012-07-29 13:03:10 +02:00
Benjamin Eberlei 5527e121ec Release 2.3.0-RC1 2012-07-29 13:03:10 +02:00
Benjamin Eberlei c55394c616 Bump dependencies 2012-07-29 13:02:58 +02:00
Benjamin Eberlei 1676cf23c0 Merge branch 'DDC-1937' into 2.3 2012-07-29 11:56:59 +02:00
Benjamin Eberlei 6dd3078153 [DDC-1937] Fix bug with apc and annotation caching using a workaround. 2012-07-29 11:56:49 +02:00
Benjamin Eberlei 00a5f18544 [DDC-1937] Fix bug with apc and annotation caching using a workaround. 2012-07-29 11:56:41 +02:00
Marco Pivetta 1e2eca1a7e DDC-1933 - Fixing cloning of QueryBuilder and adding related tests 2012-07-29 11:50:24 +02:00
Benjamin Eberlei 7029d3738d Merge branch 'DDC-1964' into 2.3 2012-07-29 11:26:55 +02:00
Benjamin Eberlei 7f68347c1f [DDC-1964] Fix issue with refresh and and object hydrator not setting field to null explicitly to override possible previous values. 2012-07-29 11:26:22 +02:00
Johannes M. Schmitt e63575ea18 added failing test for refresh with eager fetching 2012-07-29 11:26:22 +02:00
Benjamin Eberlei e8d3fc73ff Merge branch 'DDC-1964' 2012-07-29 11:25:54 +02:00
Benjamin Eberlei 7c1235dedb [DDC-1964] Fix issue with refresh and and object hydrator not setting field to null explicitly to override possible previous values. 2012-07-29 11:25:45 +02:00
Benjamin Eberlei d7bdae3bbb Merge branch 'DDC-1939' into 2.3 2012-07-29 09:28:18 +02:00
Benjamin Eberlei e2c40dc365 [DDC-1939] Add test for persistent collection delete with composite key 2012-07-29 09:27:50 +02:00
Marco Pivetta dfa6ff64c4 DDC-1939 - Removing references to non-existing AssociationMapping class 2012-07-29 09:27:50 +02:00
Benjamin Eberlei bcbef5670c Merge branch 'DDC-1939' 2012-07-29 09:27:20 +02:00
Benjamin Eberlei 354fa14df4 [DDC-1939] Add test for persistent collection delete with composite key 2012-07-29 09:27:08 +02:00
Igor Wiedler afd8ea91e3 [2.3] Use HelperSet in cli-config.php 2012-07-29 09:09:17 +02:00
Benjamin Eberlei ef27721db2 Merge remote-tracking branch 'origin/2.3' into 2.3 2012-07-29 09:08:39 +02:00
Benjamin Eberlei 13d32e6de5 Merge remote-tracking branch 'origin/2.3' into 2.3 2012-07-29 09:08:19 +02:00
Benjamin Eberlei bd1e6ac309 Merge pull request #410 from igorw/helper-set
[2.3] Use HelperSet in cli-config.php
2012-07-29 00:05:45 -07:00
Benjamin Eberlei 14bd794960 Merge pull request #411 from stof/new_types
Added the new DBAL 2.3 types in the EntityGenerator typehint map
2012-07-29 00:04:03 -07:00
Christophe Coevoet 369a30ad3d Added the new DBAL 2.3 types in the EntityGenerator typehint map 2012-07-29 09:02:35 +02:00
Christophe Coevoet cebb820030 Added the new DBAL 2.3 types in the EntityGenerator typehint map 2012-07-27 10:34:59 +02:00
Guilherme Blanco ac9df05c92 Fixed is_subclass_of comparing an interface which brought our requirement to 5.3.9. Changed to reflection approach which still keep us at the same dependency as before. 2012-07-26 22:01:37 +02:00
Guilherme Blanco 04e6cc78cd Fixed is_subclass_of comparing an interface which brought our requirement to 5.3.9. Changed to reflection approach which still keep us at the same dependency as before. 2012-07-26 15:50:51 -04:00
Igor Wiedler 2158a0788e [2.3] Use HelperSet in cli-config.php 2012-07-26 19:24:53 +02:00
Johannes M. Schmitt fc4a07c2b3 added failing test for refresh with eager fetching 2012-07-26 12:54:58 +02:00
Guilherme Blanco 2389f77d91 Fixed DefaultRepositoryClassName which should follow the Persistence interface, not ORM class. 2012-07-25 19:54:11 +02:00
Guilherme Blanco 1eaa822d2a Merge branch 'master' of github.com:doctrine/doctrine2 2012-07-25 01:24:33 -04:00
Guilherme Blanco 9dd3b66fe6 Fixed DefaultRepositoryClassName which should follow the Persistence interface, not ORM class. 2012-07-25 01:23:52 -04:00
Fabio B. Silva 1369e3d133 change ticket/group 2012-07-24 14:34:27 +02:00
Fabio B. Silva 50dac4096a give FQCN to NamingStrategy#propertyToColumnName 2012-07-24 14:34:27 +02:00
Marco Pivetta aa0cb0b6d7 DDC-1939 - Removing references to non-existing AssociationMapping class 2012-07-24 11:37:57 +02:00
Guilherme Blanco 5b55739990 Moved implementation from EntityRepository to EntityManager. This decouples ER implementation from EM, as it should be. 2012-07-24 00:23:59 +02:00
Christophe Coevoet 3e53d9d79c Changed commands to use command.name in the help 2012-07-24 00:21:31 +02:00
Guilherme Blanco 619d29adb2 Merge pull request #400 from stof/command_help
Changed commands to use command.name in the help
2012-07-22 22:04:15 -07:00
Guilherme Blanco 68adc7fed3 Merge pull request #403 from Ocramius/DDC-1925
DDC-1925 tests
2012-07-22 22:02:13 -07:00
Guilherme Blanco 98c4833afc Merge pull request #404 from Ocramius/DDC-1933
DDC-1933 - Fixing cloning of QueryBuilder and adding related tests
2012-07-22 22:01:35 -07:00
Guilherme Blanco e5979b5ef2 Moved implementation from EntityRepository to EntityManager. This decouples ER implementation from EM, as it should be. 2012-07-23 00:52:41 -04:00
Marco Pivetta fb3c6f0e8f DDC-1933 - Fixing cloning of QueryBuilder and adding related tests 2012-07-21 20:34:20 +02:00
Marco Pivetta 5b3eee8071 DDC-1925 - squashing ticket tests into a single file 2012-07-20 00:03:39 +02:00
Marco Pivetta 81f97e92d3 Adding tests for DDC-1925 2012-07-19 22:00:56 +02:00
Benjamin Eberlei 93cef61270 Fix DBAL dependency range evaluated as AND, not as OR 2012-07-18 11:23:20 +02:00
Christophe Coevoet a723b73929 Changed commands to use command.name in the help 2012-07-17 00:55:09 +02:00
Benjamin Eberlei 34ac207b3c Bump Version to 2.4.0-DEV 2012-07-16 15:25:20 +02:00
Benjamin Eberlei c8fcd3f8a5 Bump dependencies 2012-07-16 15:24:04 +02:00
Benjamin Eberlei a0ba420969 Bump dev version to 2.3.0 2012-07-16 15:23:33 +02:00
43 changed files with 456 additions and 209 deletions
+1 -1
View File
@@ -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",
+17 -3
View File
@@ -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);
}
+69 -8
View File
@@ -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);
}
}
/**
+6 -79
View File
@@ -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;
}
}
+1 -2
View File
@@ -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)
+2 -21
View File
@@ -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]];
-1
View File
@@ -21,7 +21,6 @@ namespace Doctrine\ORM\Proxy;
use Doctrine\ORM\EntityManager,
Doctrine\ORM\Mapping\ClassMetadata,
Doctrine\ORM\Mapping\AssociationMapping,
Doctrine\Common\Util\ClassUtils;
/**
+2 -2
View File
@@ -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);
}
}
}
+13 -20
View File
@@ -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;
}
}
}
+1 -1
View File
@@ -96,7 +96,7 @@ class QueryException extends \Doctrine\ORM\ORMException
}
/**
* @param \Doctrine\ORM\Mapping\AssociationMapping $assoc
* @param array $assoc
*/
public static function iterateWithFetchJoinCollectionNotAllowed($assoc)
{
+9 -1
View File
@@ -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
+2 -1
View File
@@ -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());
+1 -1
View File
@@ -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.
+1 -1
View File
@@ -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',
+2 -2
View File
@@ -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)
);
));