mirror of
https://github.com/doctrine/orm.git
synced 2026-04-24 15:08:12 +02:00
Compare commits
44 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d9fc5388f1 | |||
| d2e51eacff | |||
| 5a6ae4686f | |||
| 8b8a1cbe81 | |||
| 27a5284899 | |||
| 0086d17afe | |||
| ab62167c8a | |||
| 6d43195669 | |||
| 7065ff0ac9 | |||
| aa61328e90 | |||
| 62719f2a97 | |||
| 66770c5bfe | |||
| 42691c21b4 | |||
| 596e895763 | |||
| d5c82094df | |||
| 4148220f9c | |||
| e173c930ec | |||
| 7071984559 | |||
| 216c466233 | |||
| 65f5777e60 | |||
| 6e3ce26429 | |||
| 752d4f9eac | |||
| 2983081a60 | |||
| 464b5fdbfb | |||
| 04254a8e34 | |||
| 1d213e6733 | |||
| bc82e94afc | |||
| b9af1c8fa5 | |||
| d606efd4eb | |||
| 581e1638a2 | |||
| 17ae8d1b2d | |||
| 3a058f8522 | |||
| 567220ef71 | |||
| 39098ce415 | |||
| 1eb9c8a7f6 | |||
| f2f53ba9dc | |||
| ebbc443ec3 | |||
| 16802d2614 | |||
| ef73249bc7 | |||
| ed637e51b9 | |||
| a3ece3b419 | |||
| 2d1bc78749 | |||
| eaf8b1c7ca | |||
| 8070b50150 |
@@ -138,6 +138,10 @@ From now on, the resultset will look like this:
|
||||
...
|
||||
)
|
||||
|
||||
## Minor BC BREAK: added second parameter $indexBy in EntityRepository#createQueryBuilder method signature
|
||||
|
||||
Added way to access the underlying QueryBuilder#from() method's 'indexBy' parameter when using EntityRepository#createQueryBuilder()
|
||||
|
||||
# Upgrade to 2.4
|
||||
|
||||
## BC BREAK: Compatibility Bugfix in PersistentCollection#matching()
|
||||
|
||||
+3
-3
@@ -18,12 +18,12 @@
|
||||
"doctrine/collections": "~1.2",
|
||||
"doctrine/dbal": ">=2.5-dev,<2.6-dev",
|
||||
"doctrine/instantiator": "~1.0.1",
|
||||
"doctrine/common": ">=2.5-dev,<2.6-dev",
|
||||
"doctrine/common": ">=2.5-dev,<2.7-dev",
|
||||
"doctrine/cache": "~1.4",
|
||||
"symfony/console": "~2.5"
|
||||
"symfony/console": "~2.5|~3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/yaml": "~2.1",
|
||||
"symfony/yaml": "~2.3|~3.0",
|
||||
"phpunit/phpunit": "~4.0",
|
||||
"satooshi/php-coveralls": "dev-master"
|
||||
},
|
||||
|
||||
@@ -514,9 +514,8 @@ class YamlDriver extends FileDriver
|
||||
if ( ! isset($joinColumnElement['name'])) {
|
||||
$joinColumnElement['name'] = $joinColumnName;
|
||||
}
|
||||
$joinTable['joinColumns'][] = $this->joinColumnToArray($joinColumnElement);
|
||||
}
|
||||
|
||||
$joinTable['joinColumns'][] = $this->joinColumnToArray($joinColumnElement);
|
||||
}
|
||||
|
||||
if (isset($joinTableElement['inverseJoinColumns'])) {
|
||||
@@ -524,9 +523,8 @@ class YamlDriver extends FileDriver
|
||||
if ( ! isset($joinColumnElement['name'])) {
|
||||
$joinColumnElement['name'] = $joinColumnName;
|
||||
}
|
||||
$joinTable['inverseJoinColumns'][] = $this->joinColumnToArray($joinColumnElement);
|
||||
}
|
||||
|
||||
$joinTable['inverseJoinColumns'][] = $this->joinColumnToArray($joinColumnElement);
|
||||
}
|
||||
|
||||
$mapping['joinTable'] = $joinTable;
|
||||
|
||||
@@ -965,7 +965,7 @@ class Parser
|
||||
$schemaName = $this->em->getConfiguration()->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName;
|
||||
}
|
||||
|
||||
$exists = class_exists($schemaName, true);
|
||||
$exists = class_exists($schemaName, true) || interface_exists($schemaName, true);
|
||||
|
||||
if ( ! $exists) {
|
||||
$this->semanticalError("Class '$schemaName' is not defined.", $this->lexer->token);
|
||||
|
||||
@@ -438,8 +438,8 @@ class ResultSetMappingBuilder extends ResultSetMapping
|
||||
$sql .= $class->fieldMappings[$this->fieldMappings[$columnName]]['columnName'];
|
||||
} else if (isset($this->metaMappings[$columnName])) {
|
||||
$sql .= $this->metaMappings[$columnName];
|
||||
} else if (isset($this->discriminatorColumn[$columnName])) {
|
||||
$sql .= $this->discriminatorColumn[$columnName];
|
||||
} else if (isset($this->discriminatorColumns[$dqlAlias])) {
|
||||
$sql .= $this->discriminatorColumns[$dqlAlias];
|
||||
}
|
||||
|
||||
$sql .= " AS " . $columnName;
|
||||
|
||||
@@ -438,7 +438,10 @@ class LimitSubqueryOutputWalker extends SqlWalker
|
||||
// Field was declared in a parent class, so we need to get the proper SQL table alias
|
||||
// for the joined parent table.
|
||||
$otherClassMetadata = $this->em->getClassMetadata($fieldMapping['declared']);
|
||||
$sqlTableAliasForFieldAlias = $this->getSQLTableAlias($otherClassMetadata->getTableName(), $dqlAliasForFieldAlias);
|
||||
if (!$otherClassMetadata->isMappedSuperclass) {
|
||||
$sqlTableAliasForFieldAlias = $this->getSQLTableAlias($otherClassMetadata->getTableName(), $dqlAliasForFieldAlias);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Compose search/replace patterns
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace Doctrine\ORM\Tools;
|
||||
|
||||
use Doctrine\ORM\ORMException;
|
||||
use Doctrine\DBAL\Schema\Comparator;
|
||||
use Doctrine\DBAL\Schema\Index;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\DBAL\Schema\Table;
|
||||
use Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector;
|
||||
@@ -274,6 +275,15 @@ class SchemaTool
|
||||
|
||||
if (isset($class->table['uniqueConstraints'])) {
|
||||
foreach ($class->table['uniqueConstraints'] as $indexName => $indexData) {
|
||||
$uniqIndex = new Index($indexName, $indexData['columns'], true, false, [], isset($indexData['options']) ? $indexData['options'] : []);
|
||||
|
||||
foreach ($table->getIndexes() as $tableIndexName => $tableIndex) {
|
||||
if ($tableIndex->isFullfilledBy($uniqIndex)) {
|
||||
$table->dropIndex($tableIndexName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$table->addUniqueIndex($indexData['columns'], is_numeric($indexName) ? null : $indexName, isset($indexData['options']) ? $indexData['options'] : array());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1870,7 +1870,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
}
|
||||
}
|
||||
|
||||
if ($class->isVersioned) {
|
||||
if ($class->isVersioned && $this->isLoaded($managedCopy) && $this->isLoaded($entity)) {
|
||||
$reflField = $class->reflFields[$class->versionField];
|
||||
$managedCopyVersion = $reflField->getValue($managedCopy);
|
||||
$entityVersion = $reflField->getValue($entity);
|
||||
@@ -1883,7 +1883,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
|
||||
$visited[$oid] = $managedCopy; // mark visited
|
||||
|
||||
if (!($entity instanceof Proxy && ! $entity->__isInitialized())) {
|
||||
if ($this->isLoaded($entity)) {
|
||||
if ($managedCopy instanceof Proxy && ! $managedCopy->__isInitialized()) {
|
||||
$managedCopy->__load();
|
||||
}
|
||||
@@ -1908,6 +1908,18 @@ class UnitOfWork implements PropertyChangedListener
|
||||
return $managedCopy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if an entity is loaded - must either be a loaded proxy or not a proxy
|
||||
*
|
||||
* @param object $entity
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isLoaded($entity)
|
||||
{
|
||||
return !($entity instanceof Proxy) || $entity->__isInitialized();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets/adds associated managed copies into the previous entity's association field
|
||||
*
|
||||
|
||||
@@ -36,7 +36,7 @@ class Version
|
||||
/**
|
||||
* Current Doctrine Version
|
||||
*/
|
||||
const VERSION = '2.5.1';
|
||||
const VERSION = '2.5.3';
|
||||
|
||||
/**
|
||||
* Compares a Doctrine version with the current one.
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Marc Pantel <pantel.m@gmail.com>
|
||||
*/
|
||||
namespace Doctrine\Tests\Models\DDC3711;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
class DDC3711EntityA
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $id1;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $id2;
|
||||
|
||||
/**
|
||||
* @var ArrayCollection
|
||||
*/
|
||||
private $entityB;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getId1()
|
||||
{
|
||||
return $this->id1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $id1
|
||||
*/
|
||||
public function setId1($id1)
|
||||
{
|
||||
$this->id1 = $id1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getId2()
|
||||
{
|
||||
return $this->id2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $id2
|
||||
*/
|
||||
public function setId2($id2)
|
||||
{
|
||||
$this->id2 = $id2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArrayCollection
|
||||
*/
|
||||
public function getEntityB()
|
||||
{
|
||||
return $this->entityB;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ArrayCollection $entityB
|
||||
*
|
||||
* @return DDC3711EntityA
|
||||
*/
|
||||
public function addEntityB($entityB)
|
||||
{
|
||||
$this->entityB[] = $entityB;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Marc Pantel <pantel.m@gmail.com>
|
||||
*/
|
||||
namespace Doctrine\Tests\Models\DDC3711;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
class DDC3711EntityB
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $id1;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $id2;
|
||||
|
||||
/**
|
||||
* @var ArrayCollection
|
||||
*/
|
||||
private $entityA;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId1()
|
||||
{
|
||||
return $this->id1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id1
|
||||
*/
|
||||
public function setId1($id1)
|
||||
{
|
||||
$this->id1 = $id1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId2()
|
||||
{
|
||||
return $this->id2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id2
|
||||
*/
|
||||
public function setId2($id2)
|
||||
{
|
||||
$this->id2 = $id2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArrayCollection
|
||||
*/
|
||||
public function getEntityA()
|
||||
{
|
||||
return $this->entityA;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ArrayCollection $entityA
|
||||
*/
|
||||
public function addEntityA($entityA)
|
||||
{
|
||||
$this->entityA[] = $entityA;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\DDC3899;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="dc3899_contracts")
|
||||
* @InheritanceType("SINGLE_TABLE")
|
||||
* @DiscriminatorColumn(name="discr", type="string")
|
||||
* @DiscriminatorMap({
|
||||
* "fix" = "DDC3899FixContract",
|
||||
* "flexible" = "DDC3899FlexContract"
|
||||
* })
|
||||
*/
|
||||
abstract class DDC3899Contract
|
||||
{
|
||||
/** @Id @Column(type="integer") */
|
||||
public $id;
|
||||
|
||||
/** @Column(type="boolean") */
|
||||
public $completed = false;
|
||||
|
||||
/** @ManyToOne(targetEntity="DDC3899User", inversedBy="contract") */
|
||||
public $user;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\DDC3899;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
*/
|
||||
class DDC3899FixContract extends DDC3899Contract
|
||||
{
|
||||
/** @column(type="integer") */
|
||||
public $fixPrice = 0;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\DDC3899;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
*/
|
||||
class DDC3899FlexContract extends DDC3899Contract
|
||||
{
|
||||
/** @column(type="integer") */
|
||||
public $hoursWorked = 0;
|
||||
|
||||
/** @column(type="integer") */
|
||||
public $pricePerHour = 0;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\DDC3899;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="dc3899_users")
|
||||
*/
|
||||
class DDC3899User
|
||||
{
|
||||
/** @Id @Column(type="integer") */
|
||||
public $id;
|
||||
|
||||
/** @OneToMany(targetEntity="DDC3899Contract", mappedBy="user") */
|
||||
public $contracts;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\VersionedManyToOne;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="versioned_many_to_one_article")
|
||||
*/
|
||||
class Article
|
||||
{
|
||||
const CLASSNAME = __CLASS__;
|
||||
|
||||
/**
|
||||
* @Id
|
||||
* @Column(name="id", type="integer")
|
||||
* @GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @Column(name="name")
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="Category", cascade={"merge", "persist"})
|
||||
*/
|
||||
public $category;
|
||||
|
||||
/**
|
||||
* Version column
|
||||
*
|
||||
* @Column(type="integer", name="version")
|
||||
* @Version
|
||||
*/
|
||||
public $version;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\VersionedManyToOne;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="versioned_many_to_one_category")
|
||||
*/
|
||||
class Category
|
||||
{
|
||||
const CLASSNAME = __CLASS__;
|
||||
|
||||
/**
|
||||
* @Id
|
||||
* @Column(name="id", type="integer")
|
||||
* @GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* Version column
|
||||
*
|
||||
* @Column(type="integer", name="version")
|
||||
* @Version
|
||||
*/
|
||||
public $version;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional;
|
||||
|
||||
use Doctrine\ORM\OptimisticLockException;
|
||||
use Doctrine\ORM\ORMException;
|
||||
use Doctrine\Tests\Models\VersionedManyToOne\Article;
|
||||
use Doctrine\Tests\Models\VersionedManyToOne\Category;
|
||||
|
||||
/**
|
||||
* @group MergeVersionedOneToMany
|
||||
*/
|
||||
class MergeVersionedManyToOneTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
$this->useModelSet('versioned_many_to_one');
|
||||
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* This test case asserts that a detached and unmodified entity could be merge without firing
|
||||
* OptimisticLockException.
|
||||
*/
|
||||
public function testSetVersionOnCreate()
|
||||
{
|
||||
$category = new Category();
|
||||
$article = new Article();
|
||||
|
||||
$article->name = 'Article';
|
||||
$article->category = $category;
|
||||
|
||||
$this->_em->persist($article);
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
|
||||
$articleMerged = $this->_em->merge($article);
|
||||
|
||||
$articleMerged->name = 'Article Merged';
|
||||
|
||||
$this->_em->flush();
|
||||
$this->assertEquals(2, $articleMerged->version);
|
||||
}
|
||||
}
|
||||
@@ -791,4 +791,20 @@ class NativeQueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
|
||||
$this->assertSQLEquals('u.id AS id0, u.status AS status1, u.username AS username2, u.name AS name3, u.email_id AS email_id4', (string)$rsm);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-3899
|
||||
*/
|
||||
public function testGenerateSelectClauseWithDiscriminatorColumn()
|
||||
{
|
||||
$rsm = new ResultSetMappingBuilder($this->_em, ResultSetMappingBuilder::COLUMN_RENAMING_INCREMENT);
|
||||
$rsm->addEntityResult('Doctrine\Tests\Models\DDC3899\DDC3899User', 'u');
|
||||
$rsm->addJoinedEntityResult('Doctrine\Tests\Models\DDC3899\DDC3899FixContract', 'c', 'u', 'contracts');
|
||||
$rsm->addFieldResult('u', $this->platform->getSQLResultCasing('id'), 'id');
|
||||
$rsm->setDiscriminatorColumn('c', $this->platform->getSQLResultCasing('discr'));
|
||||
|
||||
$selectClause = $rsm->generateSelectClause(array('u' => 'u1', 'c' => 'c1'));
|
||||
|
||||
$this->assertSQLEquals('u1.id as id, c1.discr as discr', $selectClause);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,12 +45,12 @@ class QueryCacheTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$query->setQueryCacheDriver($cache);
|
||||
|
||||
$query->getResult();
|
||||
$this->assertEquals(2, $this->getCacheSize($cache));
|
||||
$this->assertEquals(1, $this->getCacheSize($cache));
|
||||
|
||||
$query->setHint('foo', 'bar');
|
||||
|
||||
$query->getResult();
|
||||
$this->assertEquals(3, $this->getCacheSize($cache));
|
||||
$this->assertEquals(2, $this->getCacheSize($cache));
|
||||
|
||||
return $query;
|
||||
}
|
||||
@@ -105,16 +105,16 @@ class QueryCacheTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
|
||||
$query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux');
|
||||
|
||||
$cache = new \Doctrine\Common\Cache\ArrayCache();
|
||||
$cache = $this->getMock('Doctrine\Common\Cache\Cache');
|
||||
|
||||
$query->setQueryCacheDriver($cache);
|
||||
|
||||
$users = $query->getResult();
|
||||
$cache
|
||||
->expects(self::once())
|
||||
->method('save')
|
||||
->with(self::isType('string'), self::isInstanceOf('Doctrine\ORM\Query\ParserResult'));
|
||||
|
||||
$data = $this->cacheDataReflection->getValue($cache);
|
||||
$this->assertEquals(2, count($data));
|
||||
|
||||
$this->assertInstanceOf('Doctrine\ORM\Query\ParserResult', array_pop($data));
|
||||
$query->getResult();
|
||||
}
|
||||
|
||||
public function testQueryCache_HitDoesNotSaveParserResult()
|
||||
|
||||
@@ -141,7 +141,7 @@ class ResultCacheTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
|
||||
$this->assertEquals(0, $this->getCacheSize($cache));
|
||||
$query->getResult();
|
||||
$this->assertEquals(2, $this->getCacheSize($cache));
|
||||
$this->assertEquals(1, $this->getCacheSize($cache));
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
@@ -343,18 +343,18 @@ class SQLFilterTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$query->setQueryCacheDriver($cache);
|
||||
|
||||
$query->getResult();
|
||||
$this->assertEquals(2, sizeof($cacheDataReflection->getValue($cache)));
|
||||
$this->assertEquals(1, sizeof($cacheDataReflection->getValue($cache)));
|
||||
|
||||
$conf = $this->_em->getConfiguration();
|
||||
$conf->addFilter("locale", "\Doctrine\Tests\ORM\Functional\MyLocaleFilter");
|
||||
$this->_em->getFilters()->enable("locale");
|
||||
|
||||
$query->getResult();
|
||||
$this->assertEquals(3, sizeof($cacheDataReflection->getValue($cache)));
|
||||
$this->assertEquals(2, sizeof($cacheDataReflection->getValue($cache)));
|
||||
|
||||
// Another time doesn't add another cache entry
|
||||
$query->getResult();
|
||||
$this->assertEquals(3, sizeof($cacheDataReflection->getValue($cache)));
|
||||
$this->assertEquals(2, sizeof($cacheDataReflection->getValue($cache)));
|
||||
}
|
||||
|
||||
public function testQueryGeneration_DependsOnFilters()
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Marc Pantel <pantel.m@gmail.com>
|
||||
*/
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||
|
||||
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
use Doctrine\Tests\ORM\Mapping\YamlMappingDriverTest;
|
||||
|
||||
class DDC3711Test extends YamlMappingDriverTest
|
||||
{
|
||||
public function testCompositeKeyForJoinTableInManyToManyCreation()
|
||||
{
|
||||
$yamlDriver = $this->_loadDriver();
|
||||
|
||||
$em = $this->_getTestEntityManager();
|
||||
$em->getConfiguration()->setMetadataDriverImpl($yamlDriver);
|
||||
$factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory();
|
||||
$factory->setEntityManager($em);
|
||||
|
||||
$entityA = new ClassMetadata('Doctrine\Tests\Models\DDC3711\DDC3711EntityA');
|
||||
$entityA = $factory->getMetadataFor('Doctrine\Tests\Models\DDC3711\DDC3711EntityA');
|
||||
|
||||
$this->assertEquals(array('link_a_id1' => "id1", 'link_a_id2' => "id2"), $entityA->associationMappings['entityB']['relationToSourceKeyColumns']);
|
||||
$this->assertEquals(array('link_b_id1' => "id1", 'link_b_id2' => "id2"), $entityA->associationMappings['entityB']['relationToTargetKeyColumns']);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,7 @@ abstract class AbstractDriverTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->setExpectedException(
|
||||
'Doctrine\Common\Persistence\Mapping\MappingException',
|
||||
"No mapping file found named '".$this->dir."/Foo".$this->getFileExtension()."' for class 'MyNamespace\MySubnamespace\Entity\Foo'."
|
||||
"No mapping file found named"
|
||||
);
|
||||
|
||||
$driver = $this->getDriver(array(
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
Doctrine\Tests\Models\DDC3711\DDC3711EntityA:
|
||||
type: entity
|
||||
table: ddc3711.entityA
|
||||
id:
|
||||
id1:
|
||||
type: int
|
||||
id2:
|
||||
type: int
|
||||
manyToMany:
|
||||
entityB:
|
||||
targetEntity: Doctrine\Tests\Models\DDC3711\DDC3711EntityB
|
||||
joinTable:
|
||||
name: link
|
||||
joinColumns:
|
||||
link_a_id1:
|
||||
referencedColumnName: id1
|
||||
link_a_id2:
|
||||
referencedColumnName: id2
|
||||
inverseJoinColumns:
|
||||
link_b_id1:
|
||||
referencedColumnName: id1
|
||||
link_b_id2:
|
||||
referencedColumnName: id2
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
Doctrine\Tests\Models\DDC3711\DDC3711EntityB:
|
||||
type: entity
|
||||
table: ddc3711.entityB
|
||||
id:
|
||||
id1:
|
||||
type: int
|
||||
id2:
|
||||
type: int
|
||||
@@ -85,6 +85,6 @@ class RunDqlCommandTest extends OrmFunctionalTestCase
|
||||
))
|
||||
);
|
||||
|
||||
$this->assertStringMatchesFormat('string%sSELECT %a', $this->tester->getDisplay());
|
||||
$this->assertStringMatchesFormat('%Astring%sSELECT %a', $this->tester->getDisplay());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -350,7 +350,26 @@ ORDER BY b.id DESC'
|
||||
$query->getSQL()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This tests ordering by property that has the 'declared' field.
|
||||
*/
|
||||
public function testLimitSubqueryOrderByFieldFromMappedSuperclass()
|
||||
{
|
||||
$this->entityManager->getConnection()->setDatabasePlatform(new MySqlPlatform());
|
||||
|
||||
// now use the third one in query
|
||||
$query = $this->entityManager->createQuery(
|
||||
'SELECT b FROM Doctrine\Tests\ORM\Tools\Pagination\Banner b ORDER BY b.id DESC'
|
||||
);
|
||||
$query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\LimitSubqueryOutputWalker');
|
||||
|
||||
$this->assertEquals(
|
||||
'SELECT DISTINCT id_0 FROM (SELECT b0_.id AS id_0, b0_.name AS name_1 FROM Banner b0_) dctrn_result ORDER BY id_0 DESC',
|
||||
$query->getSQL()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests order by on a subselect expression (mysql).
|
||||
*/
|
||||
|
||||
@@ -168,4 +168,22 @@ class Avatar
|
||||
public $image_width;
|
||||
/** @Column(type="string", length=255) */
|
||||
public $image_alt_desc;
|
||||
}
|
||||
}
|
||||
|
||||
/** @MappedSuperclass */
|
||||
abstract class Identified
|
||||
{
|
||||
/** @Id @Column(type="integer") @GeneratedValue */
|
||||
private $id;
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
}
|
||||
|
||||
/** @Entity */
|
||||
class Banner extends Identified
|
||||
{
|
||||
/** @Column(type="string") */
|
||||
public $name;
|
||||
}
|
||||
|
||||
@@ -9,19 +9,19 @@ use Doctrine\ORM\Events;
|
||||
class ResolveTargetEntityListenerTest extends \Doctrine\Tests\OrmTestCase
|
||||
{
|
||||
/**
|
||||
* @var EntityManager
|
||||
* @var \Doctrine\ORM\EntityManager
|
||||
*/
|
||||
private $em = null;
|
||||
private $em;
|
||||
|
||||
/**
|
||||
* @var ResolveTargetEntityListener
|
||||
*/
|
||||
private $listener = null;
|
||||
private $listener;
|
||||
|
||||
/**
|
||||
* @var ClassMetadataFactory
|
||||
*/
|
||||
private $factory = null;
|
||||
private $factory;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
@@ -106,6 +106,32 @@ class ResolveTargetEntityListenerTest extends \Doctrine\Tests\OrmTestCase
|
||||
$this->assertSame('Doctrine\Tests\ORM\Tools\TargetEntity', $meta['targetEntity']);
|
||||
$this->assertEquals(array('resolvetargetentity_id', 'targetinterface_id'), $meta['joinTableColumns']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group 1572
|
||||
* @group functional
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
public function testDoesResolveTargetEntitiesInDQLAlsoWithInterfaces()
|
||||
{
|
||||
$evm = $this->em->getEventManager();
|
||||
$this->listener->addResolveTargetEntity(
|
||||
'Doctrine\Tests\ORM\Tools\ResolveTargetInterface',
|
||||
'Doctrine\Tests\ORM\Tools\ResolveTargetEntity',
|
||||
array()
|
||||
);
|
||||
|
||||
$evm->addEventSubscriber($this->listener);
|
||||
|
||||
$this->assertStringMatchesFormat(
|
||||
'SELECT%AFROM ResolveTargetEntity%A',
|
||||
$this
|
||||
->em
|
||||
->createQuery('SELECT f FROM Doctrine\Tests\ORM\Tools\ResolveTargetInterface f')
|
||||
->getSQL()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
interface ResolveTargetInterface
|
||||
|
||||
@@ -116,6 +116,28 @@ class SchemaToolTest extends \Doctrine\Tests\OrmTestCase
|
||||
|
||||
$this->assertSame(array(), $customSchemaOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-3671
|
||||
*/
|
||||
public function testSchemaHasProperIndexesFromUniqueConstraintAnnotation()
|
||||
{
|
||||
$em = $this->_getTestEntityManager();
|
||||
$schemaTool = new SchemaTool($em);
|
||||
|
||||
$classes = [
|
||||
$em->getClassMetadata(__NAMESPACE__ . '\\UniqueConstraintAnnotationModel'),
|
||||
];
|
||||
|
||||
$schema = $schemaTool->getSchemaFromMetadata($classes);
|
||||
|
||||
$this->assertTrue($schema->hasTable('unique_constraint_annotation_table'));
|
||||
$table = $schema->getTable('unique_constraint_annotation_table');
|
||||
|
||||
$this->assertEquals(2, count($table->getIndexes()));
|
||||
$this->assertTrue($table->hasIndex('primary'));
|
||||
$this->assertTrue($table->hasIndex('uniq_hash'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,3 +170,20 @@ class GenerateSchemaEventListener
|
||||
$this->schemaCalled = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="unique_constraint_annotation_table", uniqueConstraints={
|
||||
* @UniqueConstraint(name="uniq_hash", columns={"hash"})
|
||||
* })
|
||||
*/
|
||||
class UniqueConstraintAnnotationModel
|
||||
{
|
||||
/** @Id @Column */
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @Column(name="hash", type="string", length=8, nullable=false, unique=true)
|
||||
*/
|
||||
private $hash;
|
||||
}
|
||||
|
||||
@@ -280,6 +280,10 @@ abstract class OrmFunctionalTestCase extends OrmTestCase
|
||||
'Doctrine\Tests\Models\Pagination\User',
|
||||
'Doctrine\Tests\Models\Pagination\User1',
|
||||
),
|
||||
'versioned_many_to_one' => array(
|
||||
'Doctrine\Tests\Models\VersionedManyToOne\Category',
|
||||
'Doctrine\Tests\Models\VersionedManyToOne\Article',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -535,6 +539,11 @@ abstract class OrmFunctionalTestCase extends OrmTestCase
|
||||
$conn->executeUpdate('DELETE FROM pagination_user');
|
||||
}
|
||||
|
||||
if (isset($this->_usedModelSets['versioned_many_to_one'])) {
|
||||
$conn->executeUpdate('DELETE FROM versioned_many_to_one_article');
|
||||
$conn->executeUpdate('DELETE FROM versioned_many_to_one_category');
|
||||
}
|
||||
|
||||
$this->_em->clear();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user