mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Compare commits
67 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b5e19dca18 | ||
|
|
585c9fd208 | ||
|
|
c6101317cd | ||
|
|
477642a171 | ||
|
|
75e968b250 | ||
|
|
3294900faa | ||
|
|
2353736e8f | ||
|
|
586aea0236 | ||
|
|
18a7fc5726 | ||
|
|
44a56e8e49 | ||
|
|
c2b82fa529 | ||
|
|
d7da012918 | ||
|
|
85e5398354 | ||
|
|
3fd8392ccf | ||
|
|
0da0d02dec | ||
|
|
387516f144 | ||
|
|
53e164ba5d | ||
|
|
4d9f24b2ee | ||
|
|
a96bbbbe0a | ||
|
|
8edecfdcad | ||
|
|
741080dc17 | ||
|
|
30ad1b0706 | ||
|
|
9cdee12ccf | ||
|
|
c76280be42 | ||
|
|
0dcfabbc4d | ||
|
|
366c6a7dd6 | ||
|
|
2597192f22 | ||
|
|
bbf527a273 | ||
|
|
9308afc9a5 | ||
|
|
1a81444b04 | ||
|
|
d181fbc98d | ||
|
|
114e233d87 | ||
|
|
bdb36a71c5 | ||
|
|
8c1d64372c | ||
|
|
f4ba58358c | ||
|
|
131d3003a0 | ||
|
|
48e94343fd | ||
|
|
9d909cd583 | ||
|
|
3aaa90e1a8 | ||
|
|
971865f271 | ||
|
|
af08f05164 | ||
|
|
2e6b50bb53 | ||
|
|
17862d9a2a | ||
|
|
c99c7b6694 | ||
|
|
3f2ddc60d4 | ||
|
|
3b3d762277 | ||
|
|
992b51eba7 | ||
|
|
5527e121ec | ||
|
|
c55394c616 | ||
|
|
1676cf23c0 | ||
|
|
6dd3078153 | ||
|
|
1e2eca1a7e | ||
|
|
7029d3738d | ||
|
|
7f68347c1f | ||
|
|
e63575ea18 | ||
|
|
d7bdae3bbb | ||
|
|
e2c40dc365 | ||
|
|
dfa6ff64c4 | ||
|
|
ef27721db2 | ||
|
|
13d32e6de5 | ||
|
|
bd1e6ac309 | ||
|
|
369a30ad3d | ||
|
|
ac9df05c92 | ||
|
|
2158a0788e | ||
|
|
2389f77d91 | ||
|
|
5b55739990 | ||
|
|
3e53d9d79c |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "doctrine/orm",
|
||||
"type": "library",
|
||||
"type": "library","version":"2.3.0",
|
||||
"description": "Object-Relational-Mapper for PHP",
|
||||
"keywords": ["orm", "database"],
|
||||
"homepage": "http://www.doctrine-project.org",
|
||||
@@ -14,7 +14,7 @@
|
||||
"require": {
|
||||
"php": ">=5.3.2",
|
||||
"ext-pdo": "*",
|
||||
"doctrine/dbal": ">=2.3-dev,<2.5-dev",
|
||||
"doctrine/dbal": "2.3.*",
|
||||
"symfony/console": "2.*"
|
||||
},
|
||||
"suggest": {
|
||||
@@ -26,7 +26,7 @@
|
||||
"bin": ["bin/doctrine", "bin/doctrine.php"],
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.4.x-dev"
|
||||
"dev-master": "2.3.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ use Doctrine\Common\Persistence\ObjectRepository;
|
||||
use Doctrine\Common\Collections\Selectable;
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\ExpressionBuilder;
|
||||
|
||||
/**
|
||||
* An EntityRepository serves as a repository for entities with generic as well as
|
||||
|
||||
@@ -1188,7 +1188,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
|
||||
// Complete fieldName and columnName mapping
|
||||
if ( ! isset($mapping['columnName'])) {
|
||||
$mapping['columnName'] = $this->namingStrategy->propertyToColumnName($mapping['fieldName'], $this->name);
|
||||
$mapping['columnName'] = $this->namingStrategy->propertyToColumnName($mapping['fieldName']);
|
||||
}
|
||||
|
||||
if ($mapping['columnName'][0] === '`') {
|
||||
@@ -1465,7 +1465,6 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
if ( ! isset($mapping['joinTable']['name'])) {
|
||||
$mapping['joinTable']['name'] = $this->namingStrategy->joinTableName($mapping['sourceEntity'], $mapping['targetEntity'], $mapping['fieldName']);
|
||||
}
|
||||
|
||||
if ( ! isset($mapping['joinTable']['joinColumns'])) {
|
||||
$mapping['joinTable']['joinColumns'] = array(array(
|
||||
'name' => $this->namingStrategy->joinKeyColumnName($mapping['sourceEntity']),
|
||||
@@ -2725,7 +2724,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
// Association defined as Id field
|
||||
$joinColumns = $this->associationMappings[$idProperty]['joinColumns'];
|
||||
$assocQuotedColumnNames = array_map(
|
||||
function ($joinColumn) {
|
||||
function ($joinColumn) use ($platform) {
|
||||
return isset($joinColumn['quoted'])
|
||||
? $platform->quoteIdentifier($joinColumn['name'])
|
||||
: $joinColumn['name'];
|
||||
|
||||
@@ -45,7 +45,7 @@ class DefaultNamingStrategy implements NamingStrategy
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function propertyToColumnName($propertyName, $className = null)
|
||||
public function propertyToColumnName($propertyName)
|
||||
{
|
||||
return $propertyName;
|
||||
}
|
||||
|
||||
@@ -197,43 +197,6 @@ class AnnotationDriver extends AbstractAnnotationDriver
|
||||
}
|
||||
}
|
||||
|
||||
$associationOverrides = array();
|
||||
// Evaluate AssociationOverrides annotation
|
||||
if (isset($classAnnotations['Doctrine\ORM\Mapping\AssociationOverrides'])) {
|
||||
$associationOverridesAnnot = $classAnnotations['Doctrine\ORM\Mapping\AssociationOverrides'];
|
||||
|
||||
foreach ($associationOverridesAnnot->value as $associationOverride) {
|
||||
// Check for JoinColummn/JoinColumns annotations
|
||||
if ($associationOverride->joinColumns) {
|
||||
$joinColumns = array();
|
||||
foreach ($associationOverride->joinColumns as $joinColumn) {
|
||||
$joinColumns[] = $this->joinColumnToArray($joinColumn);
|
||||
}
|
||||
$associationOverrides[$associationOverride->name]['joinColumns'] = $joinColumns;
|
||||
}
|
||||
|
||||
// Check for JoinTable annotations
|
||||
if ($associationOverride->joinTable) {
|
||||
$joinTable = null;
|
||||
$joinTableAnnot = $associationOverride->joinTable;
|
||||
$joinTable = array(
|
||||
'name' => $joinTableAnnot->name,
|
||||
'schema' => $joinTableAnnot->schema
|
||||
);
|
||||
|
||||
foreach ($joinTableAnnot->joinColumns as $joinColumn) {
|
||||
$joinTable['joinColumns'][] = $this->joinColumnToArray($joinColumn);
|
||||
}
|
||||
|
||||
foreach ($joinTableAnnot->inverseJoinColumns as $joinColumn) {
|
||||
$joinTable['inverseJoinColumns'][] = $this->joinColumnToArray($joinColumn);
|
||||
}
|
||||
|
||||
$associationOverrides[$associationOverride->name]['joinTable'] = $joinTable;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Evaluate InheritanceType annotation
|
||||
if (isset($classAnnotations['Doctrine\ORM\Mapping\InheritanceType'])) {
|
||||
$inheritanceTypeAnnot = $classAnnotations['Doctrine\ORM\Mapping\InheritanceType'];
|
||||
|
||||
@@ -42,10 +42,9 @@ interface NamingStrategy
|
||||
* Return a column name for a property
|
||||
*
|
||||
* @param string $propertyName A property
|
||||
* @param string $className The fully-qualified class name
|
||||
* @return string A column name
|
||||
*/
|
||||
function propertyToColumnName($propertyName, $className = null);
|
||||
function propertyToColumnName($propertyName);
|
||||
|
||||
/**
|
||||
* Return the default reference column name
|
||||
|
||||
@@ -80,7 +80,7 @@ class UnderscoreNamingStrategy implements NamingStrategy
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function propertyToColumnName($propertyName, $className = null)
|
||||
public function propertyToColumnName($propertyName)
|
||||
{
|
||||
return $this->underscore($propertyName);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -42,6 +42,7 @@ use Closure;
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @author Giorgio Sironi <piccoloprincipeazzurro@gmail.com>
|
||||
* @author Stefano Rodriguez <stefano.rodriguez@fubles.com>
|
||||
* @todo Design for inheritance to allow custom implementations?
|
||||
*/
|
||||
final class PersistentCollection implements Collection, Selectable
|
||||
@@ -812,6 +813,13 @@ final class PersistentCollection implements Collection, Selectable
|
||||
throw new \RuntimeException("Matching Criteria on PersistentCollection only works on OneToMany assocations at the moment.");
|
||||
}
|
||||
|
||||
// If there are NEW objects we have to check if any of them matches the criteria
|
||||
$newObjects = array();
|
||||
|
||||
if ($this->isDirty) {
|
||||
$newObjects = $this->coll->matching($criteria)->toArray();
|
||||
}
|
||||
|
||||
$targetClass = $this->em->getClassMetadata(get_class($this->owner));
|
||||
|
||||
$id = $targetClass->getSingleIdReflectionProperty()->getValue($this->owner);
|
||||
@@ -824,7 +832,7 @@ final class PersistentCollection implements Collection, Selectable
|
||||
|
||||
$persister = $this->em->getUnitOfWork()->getEntityPersister($this->association['targetEntity']);
|
||||
|
||||
return new ArrayCollection($persister->loadCriteria($criteria));
|
||||
return new ArrayCollection(array_merge($persister->loadCriteria($criteria), $newObjects));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -808,10 +808,23 @@ class BasicEntityPersister
|
||||
return array(array(), array());
|
||||
}
|
||||
|
||||
$valueVisitor = new SqlValueVisitor($this->_class);
|
||||
$valueVisitor = new SqlValueVisitor();
|
||||
$valueVisitor->dispatch($expression);
|
||||
|
||||
return $valueVisitor->getParamsAndTypes();
|
||||
list($values, $types) = $valueVisitor->getParamsAndTypes();
|
||||
|
||||
$sqlValues = array();
|
||||
foreach ($values as $value) {
|
||||
$sqlValues[] = $this->getValue($value);
|
||||
}
|
||||
|
||||
$sqlTypes = array();
|
||||
foreach ($types as $type) {
|
||||
list($field, $value) = $type;
|
||||
$sqlTypes[] = $this->getType($field, $value);
|
||||
}
|
||||
|
||||
return array($sqlValues, $sqlTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -46,19 +46,6 @@ class SqlValueVisitor extends ExpressionVisitor
|
||||
*/
|
||||
private $types = array();
|
||||
|
||||
/**
|
||||
* @var \Doctrine\ORM\Mapping\ClassMetadata
|
||||
*/
|
||||
private $class;
|
||||
|
||||
/**
|
||||
* @param \Doctrine\ORM\Mapping\ClassMetadata
|
||||
*/
|
||||
public function __construct(ClassMetadata $class)
|
||||
{
|
||||
$this->class = $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a comparison expression into the target query language output
|
||||
*
|
||||
@@ -70,9 +57,9 @@ class SqlValueVisitor extends ExpressionVisitor
|
||||
{
|
||||
$value = $comparison->getValue()->getValue();
|
||||
$field = $comparison->getField();
|
||||
|
||||
|
||||
$this->values[] = $value;
|
||||
$this->types[] = $this->getType($field, $value);
|
||||
$this->types[] = array($field, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,17 +97,4 @@ class SqlValueVisitor extends ExpressionVisitor
|
||||
{
|
||||
return array($this->values, $this->types);
|
||||
}
|
||||
|
||||
private function getType($field, $value)
|
||||
{
|
||||
$type = isset($this->class->fieldMappings[$field])
|
||||
? Type::getType($this->class->fieldMappings[$field]['type'])->getBindingType()
|
||||
: \PDO::PARAM_STR;
|
||||
|
||||
if (is_array($value)) {
|
||||
$type += Connection::ARRAY_PARAM_OFFSET;
|
||||
}
|
||||
|
||||
return $type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,6 +180,9 @@ class XmlExporter extends AbstractExporter
|
||||
if (isset($field['columnDefinition'])) {
|
||||
$fieldXml->addAttribute('column-definition', $field['columnDefinition']);
|
||||
}
|
||||
if (isset($field['nullable'])) {
|
||||
$fieldXml->addAttribute('nullable', $field['nullable'] ? 'true' : 'false');
|
||||
}
|
||||
}
|
||||
}
|
||||
$orderMap = array(
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -206,7 +206,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
/**
|
||||
* The EventManager used for dispatching events.
|
||||
*
|
||||
* @var EventManager
|
||||
* @var \Doctrine\Common\EventManager
|
||||
*/
|
||||
private $evm;
|
||||
|
||||
@@ -256,6 +256,9 @@ class UnitOfWork implements PropertyChangedListener
|
||||
* 5) All entity deletions
|
||||
*
|
||||
* @param null|object|array $entity
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function commit($entity = null)
|
||||
@@ -390,6 +393,9 @@ class UnitOfWork implements PropertyChangedListener
|
||||
* 4. Only if entity is properly managed.
|
||||
*
|
||||
* @param object $entity
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function computeSingleEntityChangeSet($entity)
|
||||
@@ -440,6 +446,8 @@ class UnitOfWork implements PropertyChangedListener
|
||||
/**
|
||||
* Gets the changeset for an entity.
|
||||
*
|
||||
* @param object $entity
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getEntityChangeSet($entity)
|
||||
@@ -708,8 +716,13 @@ class UnitOfWork implements PropertyChangedListener
|
||||
/**
|
||||
* Computes the changes of an association.
|
||||
*
|
||||
* @param AssociationMapping $assoc
|
||||
* @param array $assoc
|
||||
* @param mixed $value The value of the association.
|
||||
*
|
||||
* @throws ORMInvalidArgumentException
|
||||
* @throws ORMException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function computeAssociationChanges($assoc, $value)
|
||||
{
|
||||
@@ -779,6 +792,10 @@ class UnitOfWork implements PropertyChangedListener
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ClassMetadata $class
|
||||
* @param object $entity
|
||||
*/
|
||||
private function persistNew($class, $entity)
|
||||
{
|
||||
$oid = spl_object_hash($entity);
|
||||
@@ -822,7 +839,8 @@ class UnitOfWork implements PropertyChangedListener
|
||||
* @ignore
|
||||
* @param ClassMetadata $class The class descriptor of the entity.
|
||||
* @param object $entity The entity for which to (re)calculate the change set.
|
||||
* @throws InvalidArgumentException If the passed entity is not MANAGED.
|
||||
*
|
||||
* @throws ORMInvalidArgumentException If the passed entity is not MANAGED.
|
||||
*/
|
||||
public function recomputeSingleEntityChangeSet(ClassMetadata $class, $entity)
|
||||
{
|
||||
@@ -1025,6 +1043,8 @@ class UnitOfWork implements PropertyChangedListener
|
||||
/**
|
||||
* Gets the commit order.
|
||||
*
|
||||
* @param array $entityChangeSet
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getCommitOrder(array $entityChangeSet = null)
|
||||
@@ -1099,6 +1119,9 @@ class UnitOfWork implements PropertyChangedListener
|
||||
* If the entity already has an identifier, it will be added to the identity map.
|
||||
*
|
||||
* @param object $entity The entity to schedule for insertion.
|
||||
*
|
||||
* @throws ORMInvalidArgumentException
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function scheduleForInsert($entity)
|
||||
{
|
||||
@@ -1134,6 +1157,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
* Checks whether an entity is scheduled for insertion.
|
||||
*
|
||||
* @param object $entity
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isScheduledForInsert($entity)
|
||||
@@ -1145,6 +1169,8 @@ class UnitOfWork implements PropertyChangedListener
|
||||
* Schedules an entity for being updated.
|
||||
*
|
||||
* @param object $entity The entity to schedule for being updated.
|
||||
*
|
||||
* @throws ORMInvalidArgumentException
|
||||
*/
|
||||
public function scheduleForUpdate($entity)
|
||||
{
|
||||
@@ -1194,6 +1220,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
* at commit time.
|
||||
*
|
||||
* @param object $entity
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isScheduledForUpdate($entity)
|
||||
@@ -1206,6 +1233,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
* Checks whether an entity is registered to be checked in the unit of work.
|
||||
*
|
||||
* @param object $entity
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isScheduledForDirtyCheck($entity)
|
||||
@@ -1256,6 +1284,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
* of work.
|
||||
*
|
||||
* @param object $entity
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isScheduledForDelete($entity)
|
||||
@@ -1267,6 +1296,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
* Checks whether an entity is scheduled for insertion, update or deletion.
|
||||
*
|
||||
* @param $entity
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isEntityScheduled($entity)
|
||||
@@ -1286,6 +1316,9 @@ class UnitOfWork implements PropertyChangedListener
|
||||
*
|
||||
* @ignore
|
||||
* @param object $entity The entity to register.
|
||||
*
|
||||
* @throws ORMInvalidArgumentException
|
||||
*
|
||||
* @return boolean TRUE if the registration was successful, FALSE if the identity of
|
||||
* the entity in question is already managed.
|
||||
*/
|
||||
@@ -1317,6 +1350,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
* This parameter can be set to improve performance of entity state detection
|
||||
* by potentially avoiding a database lookup if the distinction between NEW and DETACHED
|
||||
* is either known or does not matter for the caller of the method.
|
||||
*
|
||||
* @return int The entity state.
|
||||
*/
|
||||
public function getEntityState($entity, $assume = null)
|
||||
@@ -1392,6 +1426,9 @@ class UnitOfWork implements PropertyChangedListener
|
||||
*
|
||||
* @ignore
|
||||
* @param object $entity
|
||||
*
|
||||
* @throws ORMInvalidArgumentException
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function removeFromIdentityMap($entity)
|
||||
@@ -1425,6 +1462,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
* @ignore
|
||||
* @param string $idHash
|
||||
* @param string $rootClassName
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function getByIdHash($idHash, $rootClassName)
|
||||
@@ -1440,6 +1478,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
* @ignore
|
||||
* @param string $idHash
|
||||
* @param string $rootClassName
|
||||
*
|
||||
* @return mixed The found entity or FALSE.
|
||||
*/
|
||||
public function tryGetByIdHash($idHash, $rootClassName)
|
||||
@@ -1455,6 +1494,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
* Checks whether an entity is registered in the identity map of this UnitOfWork.
|
||||
*
|
||||
* @param object $entity
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isInIdentityMap($entity)
|
||||
@@ -1482,6 +1522,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
* @ignore
|
||||
* @param string $idHash
|
||||
* @param string $rootClassName
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function containsIdHash($idHash, $rootClassName)
|
||||
@@ -1509,6 +1550,9 @@ class UnitOfWork implements PropertyChangedListener
|
||||
*
|
||||
* @param object $entity The entity to persist.
|
||||
* @param array $visited The already visited entities.
|
||||
*
|
||||
* @throws ORMInvalidArgumentException
|
||||
* @throws UnexpectedValueException
|
||||
*/
|
||||
private function doPersist($entity, array &$visited)
|
||||
{
|
||||
@@ -1578,7 +1622,9 @@ class UnitOfWork implements PropertyChangedListener
|
||||
*
|
||||
* @param object $entity The entity to delete.
|
||||
* @param array $visited The map of the already visited entities.
|
||||
* @throws InvalidArgumentException If the instance is a detached entity.
|
||||
*
|
||||
* @throws ORMInvalidArgumentException If the instance is a detached entity.
|
||||
* @throws UnexpectedValueException
|
||||
*/
|
||||
private function doRemove($entity, array &$visited)
|
||||
{
|
||||
@@ -1627,10 +1673,12 @@ class UnitOfWork implements PropertyChangedListener
|
||||
* Merges the state of the given detached entity into this UnitOfWork.
|
||||
*
|
||||
* @param object $entity
|
||||
* @return object The managed copy of the entity.
|
||||
*
|
||||
* @throws OptimisticLockException If the entity uses optimistic locking through a version
|
||||
* attribute and the version check against the managed copy fails.
|
||||
*
|
||||
* @return object The managed copy of the entity.
|
||||
*
|
||||
* @todo Require active transaction!? OptimisticLockException may result in undefined state!?
|
||||
*/
|
||||
public function merge($entity)
|
||||
@@ -1645,10 +1693,15 @@ class UnitOfWork implements PropertyChangedListener
|
||||
*
|
||||
* @param object $entity
|
||||
* @param array $visited
|
||||
* @return object The managed copy of the entity.
|
||||
* @param object $prevManagedCopy
|
||||
* @param array $assoc
|
||||
*
|
||||
* @throws OptimisticLockException If the entity uses optimistic locking through a version
|
||||
* attribute and the version check against the managed copy fails.
|
||||
* @throws InvalidArgumentException If the entity instance is NEW.
|
||||
* @throws ORMInvalidArgumentException If the entity instance is NEW.
|
||||
* @throws EntityNotFoundException
|
||||
*
|
||||
* @return object The managed copy of the entity.
|
||||
*/
|
||||
private function doMerge($entity, array &$visited, $prevManagedCopy = null, $assoc = null)
|
||||
{
|
||||
@@ -1895,6 +1948,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
* any local, unpersisted changes.
|
||||
*
|
||||
* @param object $entity The entity to refresh.
|
||||
*
|
||||
* @throws InvalidArgumentException If the entity is not MANAGED.
|
||||
*/
|
||||
public function refresh($entity)
|
||||
@@ -1909,7 +1963,8 @@ class UnitOfWork implements PropertyChangedListener
|
||||
*
|
||||
* @param object $entity The entity to refresh.
|
||||
* @param array $visited The already visited entities during cascades.
|
||||
* @throws InvalidArgumentException If the entity is not MANAGED.
|
||||
*
|
||||
* @throws ORMInvalidArgumentException If the entity is not MANAGED.
|
||||
*/
|
||||
private function doRefresh($entity, array &$visited)
|
||||
{
|
||||
@@ -2060,7 +2115,8 @@ class UnitOfWork implements PropertyChangedListener
|
||||
*
|
||||
* @param object $entity
|
||||
* @param array $visited
|
||||
* @param array $insertNow
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function cascadePersist($entity, array &$visited)
|
||||
{
|
||||
@@ -2144,6 +2200,12 @@ class UnitOfWork implements PropertyChangedListener
|
||||
* @param object $entity
|
||||
* @param int $lockMode
|
||||
* @param int $lockVersion
|
||||
*
|
||||
* @throws ORMInvalidArgumentException
|
||||
* @throws TransactionRequiredException
|
||||
* @throws OptimisticLockException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function lock($entity, $lockMode, $lockVersion = null)
|
||||
{
|
||||
@@ -2279,13 +2341,20 @@ class UnitOfWork implements PropertyChangedListener
|
||||
$this->collectionDeletions[$coid] = $coll;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PersistentCollection $coll
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isCollectionScheduledForDeletion(PersistentCollection $coll)
|
||||
{
|
||||
return isset($this->collectionsDeletions[spl_object_hash($coll)]);
|
||||
return isset($this->collectionDeletions[spl_object_hash($coll)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ClassMetadata $class
|
||||
*
|
||||
* @return \Doctrine\Common\Persistence\ObjectManagerAware|object
|
||||
*/
|
||||
private function newInstance($class)
|
||||
{
|
||||
@@ -2306,6 +2375,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
* @param string $className The name of the entity class.
|
||||
* @param array $data The data for the entity.
|
||||
* @param array $hints Any hints to account for during reconstitution/lookup of the entity.
|
||||
*
|
||||
* @return object The managed entity instance.
|
||||
* @internal Highly performance-sensitive method.
|
||||
*
|
||||
@@ -2578,7 +2648,9 @@ class UnitOfWork implements PropertyChangedListener
|
||||
/**
|
||||
* Initializes (loads) an uninitialized persistent collection of an entity.
|
||||
*
|
||||
* @param PeristentCollection $collection The collection to initialize.
|
||||
* @param \Doctrine\ORM\PersistentCollection $collection The collection to initialize.
|
||||
*
|
||||
* @return void
|
||||
* @todo Maybe later move to EntityManager#initialize($proxyOrCollection). See DDC-733.
|
||||
*/
|
||||
public function loadCollection(PersistentCollection $collection)
|
||||
@@ -2612,6 +2684,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
* present at the time the entity was reconstituted from the database.
|
||||
*
|
||||
* @param object $entity
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOriginalEntityData($entity)
|
||||
@@ -2654,6 +2727,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
* order as the identifier field names as returned by ClassMetadata#getIdentifierFieldNames().
|
||||
*
|
||||
* @param object $entity
|
||||
*
|
||||
* @return array The identifier values.
|
||||
*/
|
||||
public function getEntityIdentifier($entity)
|
||||
@@ -2667,6 +2741,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
*
|
||||
* @param mixed $id The entity identifier to look for.
|
||||
* @param string $rootClassName The name of the root class of the mapped entity hierarchy.
|
||||
*
|
||||
* @return mixed Returns the entity with the specified identifier if it exists in
|
||||
* this UnitOfWork, FALSE otherwise.
|
||||
*/
|
||||
@@ -2757,9 +2832,9 @@ class UnitOfWork implements PropertyChangedListener
|
||||
/**
|
||||
* Gets a collection persister for a collection-valued association.
|
||||
*
|
||||
* @param AssociationMapping $association
|
||||
* @param array $association
|
||||
*
|
||||
* @return AbstractCollectionPersister
|
||||
* @return \Doctrine\ORM\Persisters\AbstractCollectionPersister
|
||||
*/
|
||||
public function getCollectionPersister(array $association)
|
||||
{
|
||||
@@ -2901,6 +2976,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
* Helper method to initialize a lazy loading proxy or persistent collection.
|
||||
*
|
||||
* @param object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initializeObject($obj)
|
||||
@@ -2920,6 +2996,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
* Helper method to show an object as string.
|
||||
*
|
||||
* @param object $obj
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function objToStr($obj)
|
||||
@@ -2931,10 +3008,13 @@ class UnitOfWork implements PropertyChangedListener
|
||||
* Marks an entity as read-only so that it will not be considered for updates during UnitOfWork#commit().
|
||||
*
|
||||
* This operation cannot be undone as some parts of the UnitOfWork now keep gathering information
|
||||
* on this object that might be necessary to perform a correct udpate.
|
||||
* on this object that might be necessary to perform a correct update.
|
||||
*
|
||||
*
|
||||
* @param object $object
|
||||
*
|
||||
* @throws ORMInvalidArgumentException
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @param $object
|
||||
* @return void
|
||||
*/
|
||||
public function markReadOnly($object)
|
||||
@@ -2949,9 +3029,11 @@ class UnitOfWork implements PropertyChangedListener
|
||||
/**
|
||||
* Is this entity read only?
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @param $object
|
||||
* @return void
|
||||
* @param object $object
|
||||
*
|
||||
* @throws ORMInvalidArgumentException
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isReadOnly($object)
|
||||
{
|
||||
|
||||
@@ -36,7 +36,7 @@ class Version
|
||||
/**
|
||||
* Current Doctrine Version
|
||||
*/
|
||||
const VERSION = '2.4.0-DEV';
|
||||
const VERSION = '2.3.0';
|
||||
|
||||
/**
|
||||
* Compares a Doctrine version with the current one.
|
||||
|
||||
2
lib/vendor/doctrine-common
vendored
2
lib/vendor/doctrine-common
vendored
Submodule lib/vendor/doctrine-common updated: 0f7ba7fa71...d1c7d4334e
2
lib/vendor/doctrine-dbal
vendored
2
lib/vendor/doctrine-dbal
vendored
Submodule lib/vendor/doctrine-dbal updated: 659de9a189...30dc433ea0
@@ -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){}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
<?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\Functional;
|
||||
|
||||
use Doctrine\Tests\Models\Generic\DateTimeModel;
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
|
||||
/**
|
||||
* @author Josiah <josiah@jjs.id.au>
|
||||
*/
|
||||
class EntityRepositoryCriteriaTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
$this->useModelSet('generic');
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
if ($this->_em) {
|
||||
$this->_em->getConfiguration()->setEntityNamespaces(array());
|
||||
}
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function loadFixture()
|
||||
{
|
||||
$today = new DateTimeModel();
|
||||
$today->datetime =
|
||||
$today->date =
|
||||
$today->time =
|
||||
new \DateTime('today');
|
||||
$this->_em->persist($today);
|
||||
|
||||
$tomorrow = new DateTimeModel();
|
||||
$tomorrow->datetime =
|
||||
$tomorrow->date =
|
||||
$tomorrow->time =
|
||||
new \DateTime('tomorrow');
|
||||
$this->_em->persist($tomorrow);
|
||||
|
||||
$yesterday = new DateTimeModel();
|
||||
$yesterday->datetime =
|
||||
$yesterday->date =
|
||||
$yesterday->time =
|
||||
new \DateTime('yesterday');
|
||||
$this->_em->persist($yesterday);
|
||||
|
||||
$this->_em->flush();
|
||||
|
||||
unset($today);
|
||||
unset($tomorrow);
|
||||
unset($yesterday);
|
||||
|
||||
$this->_em->clear();
|
||||
}
|
||||
|
||||
public function testLteDateComparison()
|
||||
{
|
||||
$this->loadFixture();
|
||||
|
||||
$repository = $this->_em->getRepository('Doctrine\Tests\Models\Generic\DateTimeModel');
|
||||
$dates = $repository->matching(new Criteria(
|
||||
Criteria::expr()->lte('datetime', new \DateTime('today'))
|
||||
));
|
||||
|
||||
$this->assertEquals(2, count($dates));
|
||||
}
|
||||
}
|
||||
@@ -173,6 +173,30 @@ class OneToManyBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
|
||||
$this->assertInstanceOf('Doctrine\Common\Collections\Collection', $results);
|
||||
$this->assertEquals(2, count($results));
|
||||
}
|
||||
|
||||
public function testMatchingBis()
|
||||
{
|
||||
$this->_createFixture();
|
||||
|
||||
$product = $this->_em->find('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $this->product->getId());
|
||||
$features = $product->getFeatures();
|
||||
|
||||
$thirdFeature = new ECommerceFeature();
|
||||
$thirdFeature->setDescription('Third feature');
|
||||
$product->addFeature($thirdFeature);
|
||||
|
||||
$results = $features->matching(new Criteria(
|
||||
Criteria::expr()->eq('description', 'Third feature')
|
||||
));
|
||||
|
||||
$this->assertInstanceOf('Doctrine\Common\Collections\Collection', $results);
|
||||
$this->assertCount(1, $results);
|
||||
|
||||
$results = $features->matching(new Criteria());
|
||||
|
||||
$this->assertInstanceOf('Doctrine\Common\Collections\Collection', $results);
|
||||
$this->assertCount(3, $results);
|
||||
}
|
||||
|
||||
private function _createFixture()
|
||||
{
|
||||
|
||||
@@ -29,12 +29,12 @@ class MySqlSchemaToolTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$tool = new SchemaTool($this->_em);
|
||||
$sql = $tool->getCreateSchemaSql($classes);
|
||||
|
||||
$this->assertEquals("CREATE TABLE cms_groups (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(50) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDB", $sql[0]);
|
||||
$this->assertEquals("CREATE TABLE cms_users (id INT AUTO_INCREMENT NOT NULL, email_id INT DEFAULT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_3AF03EC5F85E0677 (username), UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 (email_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDB", $sql[1]);
|
||||
$this->assertEquals("CREATE TABLE cms_users_groups (user_id INT NOT NULL, group_id INT NOT NULL, INDEX IDX_7EA9409AA76ED395 (user_id), INDEX IDX_7EA9409AFE54D947 (group_id), PRIMARY KEY(user_id, group_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDB", $sql[2]);
|
||||
$this->assertEquals("CREATE TABLE cms_addresses (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, UNIQUE INDEX UNIQ_ACAC157BA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDB", $sql[3]);
|
||||
$this->assertEquals("CREATE TABLE cms_emails (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(250) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDB", $sql[4]);
|
||||
$this->assertEquals("CREATE TABLE cms_phonenumbers (phonenumber VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, INDEX IDX_F21F790FA76ED395 (user_id), PRIMARY KEY(phonenumber)) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDB", $sql[5]);
|
||||
$this->assertEquals("CREATE TABLE cms_groups (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(50) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB", $sql[0]);
|
||||
$this->assertEquals("CREATE TABLE cms_users (id INT AUTO_INCREMENT NOT NULL, email_id INT DEFAULT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_3AF03EC5F85E0677 (username), UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 (email_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB", $sql[1]);
|
||||
$this->assertEquals("CREATE TABLE cms_users_groups (user_id INT NOT NULL, group_id INT NOT NULL, INDEX IDX_7EA9409AA76ED395 (user_id), INDEX IDX_7EA9409AFE54D947 (group_id), PRIMARY KEY(user_id, group_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB", $sql[2]);
|
||||
$this->assertEquals("CREATE TABLE cms_addresses (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, UNIQUE INDEX UNIQ_ACAC157BA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB", $sql[3]);
|
||||
$this->assertEquals("CREATE TABLE cms_emails (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(250) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB", $sql[4]);
|
||||
$this->assertEquals("CREATE TABLE cms_phonenumbers (phonenumber VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, INDEX IDX_F21F790FA76ED395 (user_id), PRIMARY KEY(phonenumber)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB", $sql[5]);
|
||||
$this->assertEquals("ALTER TABLE cms_users ADD CONSTRAINT FK_3AF03EC5A832C1C9 FOREIGN KEY (email_id) REFERENCES cms_emails (id)", $sql[6]);
|
||||
$this->assertEquals("ALTER TABLE cms_users_groups ADD CONSTRAINT FK_7EA9409AA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id)", $sql[7]);
|
||||
$this->assertEquals("ALTER TABLE cms_users_groups ADD CONSTRAINT FK_7EA9409AFE54D947 FOREIGN KEY (group_id) REFERENCES cms_groups (id)", $sql[8]);
|
||||
@@ -54,7 +54,7 @@ class MySqlSchemaToolTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$sql = $tool->getCreateSchemaSql($classes);
|
||||
|
||||
$this->assertEquals(1, count($sql));
|
||||
$this->assertEquals("CREATE TABLE decimal_model (id INT AUTO_INCREMENT NOT NULL, `decimal` NUMERIC(5, 2) NOT NULL, `high_scale` NUMERIC(14, 4) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDB", $sql[0]);
|
||||
$this->assertEquals("CREATE TABLE decimal_model (id INT AUTO_INCREMENT NOT NULL, `decimal` NUMERIC(5, 2) NOT NULL, `high_scale` NUMERIC(14, 4) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB", $sql[0]);
|
||||
}
|
||||
|
||||
public function testGetCreateSchemaSql3()
|
||||
@@ -67,7 +67,7 @@ class MySqlSchemaToolTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$sql = $tool->getCreateSchemaSql($classes);
|
||||
|
||||
$this->assertEquals(1, count($sql));
|
||||
$this->assertEquals("CREATE TABLE boolean_model (id INT AUTO_INCREMENT NOT NULL, booleanField TINYINT(1) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDB", $sql[0]);
|
||||
$this->assertEquals("CREATE TABLE boolean_model (id INT AUTO_INCREMENT NOT NULL, booleanField TINYINT(1) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB", $sql[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
62
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1918Test.php
Normal file
62
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1918Test.php
Normal file
@@ -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)));
|
||||
}
|
||||
}
|
||||
@@ -1,182 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
require_once __DIR__ . '/../../../TestInit.php';
|
||||
|
||||
/**
|
||||
* @group DDC-1925
|
||||
* @group DDC-1210
|
||||
*/
|
||||
class DDC1925Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
{
|
||||
public function testIssue()
|
||||
{
|
||||
$this->_schemaTool->createSchema(array(
|
||||
$this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1925User'),
|
||||
$this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1925Product'),
|
||||
));
|
||||
|
||||
$user = new DDC1925User();
|
||||
$user->setTitle("Test User");
|
||||
$this->_em->persist($user);
|
||||
|
||||
$product = new DDC1925Product();
|
||||
$product->setTitle("Test product");
|
||||
$this->_em->persist($product);
|
||||
$this->_em->flush();
|
||||
|
||||
$product->addBuyer($user);
|
||||
|
||||
$this->_em->getUnitOfWork()->computeChangeSets();
|
||||
|
||||
$this->_em->persist($product);
|
||||
$this->_em->flush();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Table
|
||||
* @Entity
|
||||
*/
|
||||
class DDC1925Product
|
||||
{
|
||||
/**
|
||||
* @var integer $id
|
||||
*
|
||||
* @Column(name="id", type="integer")
|
||||
* @Id
|
||||
* @GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string $title
|
||||
*
|
||||
* @Column(name="title", type="string", length=255)
|
||||
*/
|
||||
private $title;
|
||||
|
||||
/**
|
||||
* @ManyToMany(targetEntity="DDC1925User")
|
||||
* @JoinTable(
|
||||
* name="user_purchases",
|
||||
* joinColumns={@JoinColumn(name="product_id", referencedColumnName="id")},
|
||||
* inverseJoinColumns={@JoinColumn(name="user_id", referencedColumnName="id")}
|
||||
* )
|
||||
*/
|
||||
private $buyers;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->buyers = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return integer
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $title
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $buyers
|
||||
*/
|
||||
public function setBuyers($buyers)
|
||||
{
|
||||
$this->buyers = $buyers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBuyers()
|
||||
{
|
||||
return $this->buyers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DDC1925User $buyer
|
||||
*/
|
||||
public function addBuyer(DDC1925User $buyer)
|
||||
{
|
||||
$this->buyers[] = $buyer;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Table
|
||||
* @Entity
|
||||
*/
|
||||
class DDC1925User
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*
|
||||
* @Column(name="id", type="integer")
|
||||
* @Id
|
||||
* @GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @Column(name="title", type="string", length=255)
|
||||
*/
|
||||
private $title;
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title
|
||||
*
|
||||
* @param string $title
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
}
|
||||
@@ -922,26 +922,6 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
||||
$this->assertEquals('doctrineglobal_article_cms_cmsuser', $articleMetadata->associationMappings['author']['joinTable']['name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-984
|
||||
* @group DDC-559
|
||||
*/
|
||||
public function testFullyQualifiedClassNameShouldBeGivenToNamingStrategyPropertyToColumnName()
|
||||
{
|
||||
$namingStrategy = new MyPrefixNamingStrategy();
|
||||
$metadata = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress', $namingStrategy);
|
||||
|
||||
$metadata->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
||||
|
||||
$metadata->mapField(array('fieldName'=>'country'));
|
||||
$metadata->mapField(array('fieldName'=>'city'));
|
||||
|
||||
$this->assertEquals($metadata->fieldNames, array(
|
||||
'cmsaddress_country' => 'country',
|
||||
'cmsaddress_city' => 'city'
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-1746
|
||||
*/
|
||||
@@ -1013,14 +993,3 @@ class MyNamespacedNamingStrategy extends \Doctrine\ORM\Mapping\DefaultNamingStra
|
||||
return strtolower($className);
|
||||
}
|
||||
}
|
||||
|
||||
class MyPrefixNamingStrategy extends \Doctrine\ORM\Mapping\DefaultNamingStrategy
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function propertyToColumnName($propertyName, $className = null)
|
||||
{
|
||||
return strtolower($this->classToTableName($className)) . '_' . $propertyName;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user