[DDC-3517] [GH-1265] Fix error undefined index "targetEntity" in persister Created: 18/Jan/15  Updated: 28/Jan/15  Resolved: 18/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: Git Master
Fix Version/s: 2.5
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: inheritance, one-to, onetoone, persister, sti


 Description   

This issue is created automatically through a Github pull request on behalf of andersonamuller:

Url: https://github.com/doctrine/doctrine2/pull/1265

Message:



 Comments   
Comment by Doctrine Bot [ 18/Jan/15 ]

A related Github Pull-Request [GH-1265] was assigned:
https://github.com/doctrine/doctrine2/pull/1265

Comment by Doctrine Bot [ 18/Jan/15 ]

A related Github Pull-Request [GH-1265] was merged:
https://github.com/doctrine/doctrine2/pull/1265





[DDC-3544] [GH-1288] Hotfix - #1169 - extra lazy one to many must be no-op when not doing orphan removal Created: 27/Jan/15  Updated: 28/Jan/15  Resolved: 28/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Lazy Loading, ORM
Affects Version/s: 2.5
Fix Version/s: 2.5
Security Level: All

Type: Bug Priority: Blocker
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: collection, extra-lazy, lazy-loading, onetomany, orphanRemoval

Issue Links:
Dependency
is required for DDC-3343 `PersistentCollection::removeElement`... Resolved
is required for DDC-3536 [GH-1281] Hotfix/#1169 extra lazy one... Resolved

 Description   

This issue is created automatically through a Github pull request on behalf of Ocramius:

Url: https://github.com/doctrine/doctrine2/pull/1288

Message:

See https://github.com/doctrine/doctrine2/pull/1281#issuecomment-71403668



 Comments   
Comment by Doctrine Bot [ 28/Jan/15 ]

A related Github Pull-Request [GH-1288] was labeled:
https://github.com/doctrine/doctrine2/pull/1288

Comment by Doctrine Bot [ 28/Jan/15 ]

A related Github Pull-Request [GH-1288] was assigned:
https://github.com/doctrine/doctrine2/pull/1288

Comment by Doctrine Bot [ 28/Jan/15 ]

A related Github Pull-Request [GH-1288] was merged:
https://github.com/doctrine/doctrine2/pull/1288





[DDC-3548] [GH-1291] Conversion to PHP 5.4's short array syntax Created: 28/Jan/15  Updated: 28/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of BenMorel:

Url: https://github.com/doctrine/doctrine2/pull/1291

Message:

Now that the minimum PHP version is 5.4, it would be good to encourage the use of the short array syntax `[]`.
Converting the existing codebase to this syntax will promote this good practice and encourage everyone to follow it.

I have converted the codebase with [a tool](https://gist.github.com/BenMorel/6994483) I wrote for personal projects:

find doctrine2 -type f -name '*.php' -exec php short-array-syntax-converter.php {} \;

The number of changes is quite large, but I'm confident that nothing is broken, and the passing tests confirm this.



 Comments   
Comment by Doctrine Bot [ 28/Jan/15 ]

A related Github Pull-Request [GH-1291] was assigned:
https://github.com/doctrine/doctrine2/pull/1291





[DDC-3346] findOneBy returns an object with partial collection for the properties with mapping oneToMany/Fetch Eager Created: 10/Oct/14  Updated: 28/Jan/15  Resolved: 25/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: Git Master
Fix Version/s: 2.5
Security Level: All

Type: Bug Priority: Critical
Reporter: Adrien Russo Assignee: Marco Pivetta
Resolution: Fixed Votes: 2
Labels: collection, eager, fetch, lazy-loading, many-to-many, onetomany, persister

Issue Links:
Dependency
depends on DDC-3534 [GH-1280] [DDC-3346] #1277 find one w... Open
depends on DDC-3531 [GH-1277] [DDC-3346] Failing test for... Resolved

 Description   

findOneBy returns an object with partial collection for the properties with mapping oneToMany/Fetch Eager. This bug appear only for entities without inheritance.

Mapping
       
Test\Bar:
    type: entity
    table: bar
    fields:
        code:
            type: string
    oneToMany:
        posts:
            targetEntity: Test\Post
            fetch: EAGER
            mappedBy: bar
            cascade: ['all']
    
Test\Post:
    type: entity
    table: post
    fields:
        content:
            type: text
    manyToOne:
        bar:
            targetEntity: Test\Bar
            cascade: []
            joinColumn:
                name: bar_id
                referencedColumnName: id
Data
    
$bar = new \Test\Bar('foo');
$bar->addPost(
  new Test\Post('toto')
);
$bar->addPost(
  new Test\Post('tata')
);
 
$bar->getPosts()->count(); #value is 2
$manager->persist($bar);
$manager->flush();
FindOneBy with fetch eager
$bar = $repository->findOneBy(['code' => 'foo']);
$bar->getPosts()->count(); #value is 1
FindOneBy with fetch Lazy
$bar = $repository->findOneBy(['code' => 'foo']);
$bar->getPosts()->count(); #value is 2

I think this bug is due to the LIMIT 1 clause happening on findOneBy which also applies on joins generated here.

For instance, the generated SQL statement generated might look like

Sql Statement
SELECT
	t0. ID AS id_1,
	t0.code AS code_2,
	t1. ID AS id_3,
	t1.content AS content_4,
	t1.bar_id AS bar_id_5
FROM
	bar t0
LEFT JOIN post t1 ON t1.bar_id = t0. ID
WHERE
	t0. code = 'foo'
LIMIT 1


 Comments   
Comment by Pavel Batanov [ 22/Jan/15 ]

Still expiriencing it at 2.5.0-alpha (b889e18a9a15c36eac7349b06cb4b0f955a9da57). findOneBy cuts many-to-many association with fetch eager by 'LIMIT 1'

Comment by Marco Pivetta [ 22/Jan/15 ]

Pavel Batanov yeah, we don't have a fix for it yet: I suggest providing a PR with the failing test first, and if we can't get to it, trying to patch it yourself, or at least find out which code bit affects this behavior.

Comment by Pavel Batanov [ 22/Jan/15 ]

I'm finishing such PR now. Will supply it to github soon

Comment by Pavel Batanov [ 22/Jan/15 ]

here it is
https://github.com/doctrine/doctrine2/pull/1277
http://www.doctrine-project.org/jira/browse/DDC-3531

Here is the failed travis build
https://travis-ci.org/scaytrase/doctrine2/jobs/47921568

Comment by Doctrine Bot [ 23/Jan/15 ]

A related Github Pull-Request [GH-1277] was assigned:
https://github.com/doctrine/doctrine2/pull/1277

Comment by Doctrine Bot [ 23/Jan/15 ]

A related Github Pull-Request [GH-1277] was closed:
https://github.com/doctrine/doctrine2/pull/1277

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1280] was labeled:
https://github.com/doctrine/doctrine2/pull/1280

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1277] was labeled:
https://github.com/doctrine/doctrine2/pull/1277

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1280] was assigned:
https://github.com/doctrine/doctrine2/pull/1280

Comment by Doctrine Bot [ 25/Jan/15 ]

A related Github Pull-Request [GH-1280] was merged:
https://github.com/doctrine/doctrine2/pull/1280

Comment by Marco Pivetta [ 25/Jan/15 ]

Handled in DDC-3534

Comment by Matteo Beccati [ 28/Jan/15 ]

FYI the test is failing on: https://revive.beccati.com/bamboo/browse/PHP-DOCTR-PHP54-249/test/case/18357533

As far as I can tell from https://www.sqlite.org/lang_select.html SQLite doesn't support OFFSET w/o LIMIT.

Doctrine\Tests\ORM\Functional\Ticket\DDC3346Test::testFindWithEagerFetchAndOffsetWillNotHydrateLimitedCollection
Exception: [Doctrine\DBAL\Exception\SyntaxErrorException] An exception occurred while executing 'SELECT t0.id AS id_1, t0.username AS username_2 FROM ddc3346_users t0 WHERE t0.username = ? OFFSET 0' with params ["bwoogy"]:

SQLSTATE[HY000]: General error: 1 near "OFFSET": syntax error

With queries:
6. SQL: '"COMMIT"' Params: 
5. SQL: 'INSERT INTO ddc3346_articles (user_id) VALUES (?)' Params: '1'
4. SQL: 'INSERT INTO ddc3346_articles (user_id) VALUES (?)' Params: '1'
3. SQL: 'INSERT INTO ddc3346_users (username) VALUES (?)' Params: 'bwoogy'
2. SQL: '"START TRANSACTION"' Params: 

Trace:
/home/atlassian/bamboo/xml-data/build-dir/PHP-DOCTR-PHP54/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:116
/home/atlassian/bamboo/xml-data/build-dir/PHP-DOCTR-PHP54/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:838
/home/atlassian/bamboo/xml-data/build-dir/PHP-DOCTR-PHP54/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:875
/home/atlassian/bamboo/xml-data/build-dir/PHP-DOCTR-PHP54/lib/Doctrine/ORM/EntityRepository.php:181
/home/atlassian/bamboo/xml-data/build-dir/PHP-DOCTR-PHP54/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3346Test.php:53
/home/atlassian/bamboo/xml-data/build-dir/PHP-DOCTR-PHP54/vendor/phpunit/phpunit/src/Framework/TestCase.php:860
/home/atlassian/bamboo/xml-data/build-dir/PHP-DOCTR-PHP54/vendor/phpunit/phpunit/src/Framework/TestCase.php:737
/home/atlassian/bamboo/xml-data/build-dir/PHP-DOCTR-PHP54/vendor/phpunit/phpunit/src/Framework/TestResult.php:609
/home/atlassian/bamboo/xml-data/build-dir/PHP-DOCTR-PHP54/vendor/phpunit/phpunit/src/Framework/TestCase.php:693
/home/atlassian/bamboo/xml-data/build-dir/PHP-DOCTR-PHP54/vendor/phpunit/phpunit/src/Framework/TestSuite.php:716
/home/atlassian/bamboo/xml-data/build-dir/PHP-DOCTR-PHP54/vendor/phpunit/phpunit/src/Framework/TestSuite.php:716
/home/atlassian/bamboo/xml-data/build-dir/PHP-DOCTR-PHP54/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:398
phar:///home/atlassian/bin/phpunit.phar/phpunit/TextUI/Command.php:179
phar:///home/atlassian/bin/phpunit.phar/phpunit/TextUI/Command.php:132
/home/atlassian/bin/phpunit.phar:584
Comment by Steve Müller [ 28/Jan/15 ]

Matteo Beccati I believe this is fixed already by https://github.com/doctrine/dbal/pull/782

Comment by Matteo Beccati [ 28/Jan/15 ]

My mistake. The build wasn't cleaning up the vendor dir before running composer update, so it was still using an old dbal.





[DDC-2093] Doctrine Criteria does not support sorting by relationed field Created: 20/Oct/12  Updated: 28/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: Git Master
Fix Version/s: None
Security Level: All

Type: Improvement Priority: Major
Reporter: Bogdan Yurov Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   
// Here I call Criteria filter
public function getWalletsActive() {
	$criteria = Criteria::create()
		->where(Criteria::expr()->eq("isRemoved", "0"))
		->orderBy(array("currency.id" => "ASC"));
	return $this->wallets->matching($criteria);
}

// Relation
/**
 * @var Currency
 *
 * @ORM\ManyToOne(targetEntity="Currency")
 * @ORM\JoinColumns({
 * @ORM\JoinColumn(name="id_currency", referencedColumnName="id")
 * })
 */
protected $currency;

// File BasicEntityPersister.php
// This cause the problem:
if ( ! isset($this->_class->fieldMappings[$fieldName])) {
    throw ORMException::unrecognizedField($fieldName);
}
// There are no relations in $this->_class->fieldMappings at all!


 Comments   
Comment by Benjamin Eberlei [ 06/Jan/13 ]

Mark as improvement.

Comment by Liverbool [ 28/Jan/15 ]

How about this?

Comment by Marco Pivetta [ 28/Jan/15 ]

Liverbool give it a try and open a PR





[DDC-3547] [GH-1290] [Doc] [Reference] [Second Level Cache] Created: 27/Jan/15  Updated: 27/Jan/15  Resolved: 27/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Documentation
Affects Version/s: None
Fix Version/s: 2.5
Security Level: All

Type: Documentation Priority: Trivial
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: typo


 Description   

This issue is created automatically through a Github pull request on behalf of phansys:

Url: https://github.com/doctrine/doctrine2/pull/1290

Message:

Updated reference for Second Level Cache (fixed some typos and docblocks).



 Comments   
Comment by Doctrine Bot [ 27/Jan/15 ]

A related Github Pull-Request [GH-1290] was assigned:
https://github.com/doctrine/doctrine2/pull/1290

Comment by Doctrine Bot [ 27/Jan/15 ]

A related Github Pull-Request [GH-1290] was merged:
https://github.com/doctrine/doctrine2/pull/1290





[DDC-3540] [GH-1285] travis: remove unnecessary database creation Created: 25/Jan/15  Updated: 27/Jan/15  Resolved: 27/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Tools
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Improvement Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Duplicate Votes: 0
Labels: ci, performance, setup, travis

Issue Links:
Duplicate
duplicates DDC-3546 [GH-1289] Improve test suite Resolved
Reference
relates to DDC-3532 [GH-1278] travis: remove unnecessary ... Resolved
is referenced by DDC-3546 [GH-1289] Improve test suite Resolved

 Description   

This issue is created automatically through a Github pull request on behalf of TomasVotruba:

Url: https://github.com/doctrine/doctrine2/pull/1285

Message:

Ref: #1278



 Comments   
Comment by Doctrine Bot [ 25/Jan/15 ]

A related Github Pull-Request [GH-1285] was assigned:
https://github.com/doctrine/doctrine2/pull/1285

Comment by Doctrine Bot [ 25/Jan/15 ]

A related Github Pull-Request [GH-1285] was labeled:
https://github.com/doctrine/doctrine2/pull/1285

Comment by Doctrine Bot [ 27/Jan/15 ]

A related Github Pull-Request [GH-1285] was closed:
https://github.com/doctrine/doctrine2/pull/1285





[DDC-3546] [GH-1289] Improve test suite Created: 27/Jan/15  Updated: 27/Jan/15  Resolved: 27/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: 2.5
Security Level: All

Type: Improvement Priority: Minor
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: ci, performance, phpunit, testing, travis

Issue Links:
Duplicate
is duplicated by DDC-3540 [GH-1285] travis: remove unnecessary ... Resolved
Reference
relates to DDC-3540 [GH-1285] travis: remove unnecessary ... Resolved

 Description   

This issue is created automatically through a Github pull request on behalf of deeky666:

Url: https://github.com/doctrine/doctrine2/pull/1289

Message:

This PR adopts DBAL's latest test suite improvements from https://github.com/doctrine/dbal/pull/597/files, https://github.com/doctrine/dbal/pull/643/files, https://github.com/doctrine/dbal/pull/779 and https://github.com/doctrine/dbal/pull/758/files
Supersedes https://github.com/doctrine/doctrine2/pull/1285



 Comments   
Comment by Doctrine Bot [ 27/Jan/15 ]

A related Github Pull-Request [GH-1289] was assigned:
https://github.com/doctrine/doctrine2/pull/1289

Comment by Doctrine Bot [ 27/Jan/15 ]

A related Github Pull-Request [GH-1285] was closed:
https://github.com/doctrine/doctrine2/pull/1285

Comment by Doctrine Bot [ 27/Jan/15 ]

A related Github Pull-Request [GH-1289] was merged:
https://github.com/doctrine/doctrine2/pull/1289





[DDC-2693] Attribute/association overrides should be ignored when generating entities Created: 19/Sep/13  Updated: 27/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.4, 2.3.4
Fix Version/s: None
Security Level: All

Type: Bug Priority: Minor
Reporter: Joris van de Sande Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 9
Labels: command

Issue Links:
Duplicate
is duplicated by DDC-3109 [Doctrine\ORM\Mapping\MappingExceptio... Open

 Description   

The "orm:generate-entities" command fails when doctrine attribute and/or association overrides are used. So from the moment that you use an attribute/association override, it is implossible to use the generate entities command. I think that the solution to this problem is to ignore the overrides when generating entities.

The exception given in case of an attribute override is (this is executed within a Symfony2 project doctrine:generate:entities):

Generating entity "My\AppBundle\Entity\Job"

  [Doctrine\ORM\Mapping\MappingException]
  Invalid field override named 'value' for class 'My\AppBundle\Entity\Job'.

Exception trace:
 () at /path/to/project/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/MappingException.php:89
 Doctrine\ORM\Mapping\MappingException::invalidOverrideFieldName() at /path/to/project/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php:1922
 Doctrine\ORM\Mapping\ClassMetadataInfo->setAttributeOverride() at /path/to/project/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php:564
 Doctrine\ORM\Mapping\Driver\YamlDriver->loadMetadataForClass() at /path/to/project/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php:104
 Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain->loadMetadataForClass() at /path/to/project/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:113
 Doctrine\ORM\Mapping\ClassMetadataFactory->doLoadMetadata() at /path/to/project/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:302
 Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->loadMetadata() at /path/to/project/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:212
 Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getMetadataFor() at /path/to/project/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:112
 Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getAllMetadata() at /path/to/project/vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/Mapping/MetadataFactory.php:196
 Doctrine\Bundle\DoctrineBundle\Mapping\MetadataFactory->getAllMetadata() at /path/to/project/vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/Mapping/MetadataFactory.php:176
 Doctrine\Bundle\DoctrineBundle\Mapping\MetadataFactory->getMetadataForClass() at /path/to/project/vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/Mapping/MetadataFactory.php:76
 Doctrine\Bundle\DoctrineBundle\Mapping\MetadataFactory->getClassMetadata() at /path/to/project/vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/Command/GenerateEntitiesDoctrineCommand.php:106
 Doctrine\Bundle\DoctrineBundle\Command\GenerateEntitiesDoctrineCommand->execute() at /path/to/project/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:242
 Symfony\Component\Console\Command\Command->run() at /path/to/project/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:200
 Symfony\Component\Console\Application->doRun() at /path/to/project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:83
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /path/to/project/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:106
 Symfony\Component\Console\Application->run() at /path/to/project/app/console:19


 Comments   
Comment by Rein Baarsma [ 27/Feb/14 ]

I have the same issue and it's easy to reproduce with a clean Symfony 2 setup with FOSUserBundle.
Once you add

 * @ORM\AttributeOverrides({
 *      @ORM\AttributeOverride(name="usernameCanonical",
 *          column=@ORM\Column(
 *              name     = "username_canonical",
 *              type     = "string",
 *              length   = 255,
 *              unique   = false
 *          )
 *      )
 * })

It will properly do doc:schema:update --force
But it will fail on doc:gen:entities (YourEntity)

Comment by Andy Waterman [ 13/Aug/14 ]

Not sure I agree this is minor - might not affect many users, but it's pretty blocking if you do run into it. Any ideas on a fix?

Comment by Marco Pivetta [ 13/Aug/14 ]

Andy Waterman you are supposed to manually edit generated entities anyway

Comment by Andy Waterman [ 19/Aug/14 ]

" you are supposed to manually edit generated entities anyway"

This applies to creating new entities as well as adapting old ones. Ie. Once you use an AttributeOverride anywhere in your project, you then cannot use generate:entities anywhere else.

Comment by Marco Pivetta [ 19/Aug/14 ]

Andy Waterman yes, and you are supposed to avoid the generator after the first run.

Comment by Andy Waterman [ 20/Aug/14 ]

You really cannot use the generate:entities command to generate method stubs in ANY of your entities or new entities after the first time you run it??

If this use case works as designed without AttributeOverride in the project, but not with AttributeOverrides, then it's a bug not us doing it wrong.

Comment by Cliff Odijk [ 20/Aug/14 ]

I agree with Andy Waterman that this is a bug if it works al the time and not when you use AttributeOverrides.

Now we just temporary remove the AttributeOverrides and then generate our stubs.

Comment by Cliff Odijk [ 12/Sep/14 ]

I tried to debug the issue and found that during the gatering of the class metadata you will get the DisconnectedClassMetadataFactory which gives the StaticReflectionService for the getParentClasses it returns an empty array which should be al the parent classes of an entity. Because of this the mapping information of the parent class does not exists and can't be overwritten.

Comment by Cliff Odijk [ 12/Sep/14 ]

If I implement the following code in the getParentClasses of the StaticReflectionService it work's like a charm

if ( ! class_exists($class)) {
            throw MappingException::nonExistingClass($class);
        }

        return class_parents($class);
Comment by Enrico Schultz [ 27/Jan/15 ]

This bug has been fixed by fixing DDC-1379. If you use protected variables in your base class, the schema is created correctly and the entity generator also does not generate properties twice. When using Symfony2, just set "doctrine/orm" to "2.4@dev" in "composer.json" or wait for an upcoming release.





[DDC-3545] Persist new object failed when it works with optimistic lock Created: 27/Jan/15  Updated: 27/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.4
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Max Liu Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: dql, orm
Environment:

PHP 5.5



 Description   

When I was trying to persist a new object, Doctrine reported a exception:

An exception occurred while executing 'SELECT version FROM wallet WHERE user_id = ?' with params [{}]:

Catchable Fatal Error: Object of class XXXBundle\Entity\User could not be converted to string in /Users/XXX/WebSite/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php line 91

From the stack trace information, I found the original exception is:

Catchable Fatal Error: Object of class XXXBundle\Entity\User could not be converted to string

The reason is that the entity Wallet has a OneToOne mapping to entity User, and user property is also marked as primary key. When the wallet object persists, Doctrine try to fetch the new version id and use user property to find object. But Doctrine doesn't handle the primary key is an object, not a basic type. So PDO can't use a object as a query parameter.

My Entity:

class Wallet
{
    /**
     * ID
     * @var User
     *
     * @ORM\Id
     * @ORM\OneToOne(targetEntity="XXXBundle\Entity\User")
     * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
     */
    private $user;

    /**
     * @var int
     *
     * @ORM\Version()
     * @ORM\Column(name="version", type="integer")
     */
    private $version;
}

I hope Doctrine team can solve this problem. My temporary solution is to override __toString method in User object. It is not elegant, doesn't it?



 Comments   
Comment by Marco Pivetta [ 27/Jan/15 ]

What exact version of the ORM is affected? Is master also behaving like this?

Comment by Max Liu [ 27/Jan/15 ]

It works well before I add version field. I didn't try with master version.





[DDC-3343] `PersistentCollection::removeElement` schedules an entity for deletion when relationship is EXTRA_LAZY, with `orphanRemoval` false. Created: 09/Oct/14  Updated: 27/Jan/15  Resolved: 25/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.2, 2.3, 2.4
Fix Version/s: 2.5, 2.4.8

Type: Bug Priority: Blocker
Reporter: Andrea Sprega Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: mapping, orm

Issue Links:
Dependency
depends on DDC-3536 [GH-1281] Hotfix/#1169 extra lazy one... Resolved
depends on DDC-3544 [GH-1288] Hotfix - #1169 - extra lazy... Resolved
depends on DDC-3537 [GH-1282] Hotfix/#1169 extra lazy one... Resolved

 Description   

Given the following entity for which I only report the relevant association:

class Group
{
    /**
     * @ORM\OneToMany(targetEntity="User", mappedBy="group", fetch="EXTRA_LAZY")
     */
    protected $users;
    //...
}

and its inverse

class User
{
    /**
     * @ORM\ManyToOne(targetEntity="Group", inversedBy="users")
     * @ORM\JoinColumn(name="group_id", onDelete="SET NULL")
     */
    protected $group;
    //...
}

I experience a weird issue when, inside Group, I call $this->users->removeElement($user): Doctrine schedules the $user entity for deletion, no matter what (it doesn't check for the orphanRemoval attribute). Also, even re-adding the entity to a new Group before the flush() occurs doesn't prevent it from being deleted.

I believe this is a bug, since I do not see any special mention of this behavior in the documentation for extra lazy associations:
http://doctrine-orm.readthedocs.org/en/latest/tutorials/extra-lazy-associations.html.

The workaround for me has been to remove fetch="EXTRA_LAZY" from the relationship.

After digging a little bit into the source code, this seems to be the commit (and the line) that introduced this behavior:

https://github.com/doctrine/doctrine2/commit/356f5874bf81ca4e37681c233e24cc84d16e7a39#diff-108586f774fc8acb02163ed709e05e86R403

I also found this on Google:

https://groups.google.com/forum/#!topic/doctrine-user/cx_yBuoqiAE

which basically didn't help much, except for suggesting that it should be a feature when there is an orphanRemoval and/or a cascade operation in place (and that makes perfectly sense).

I set this to "critical" since (as it occurred to me) it can lead to irrecoverable data loss.

Is this effectively a bug?



 Comments   
Comment by Marco Pivetta [ 25/Jan/15 ]

Fixed via DDC-3536 and DDC-3537





[DDC-3536] [GH-1281] Hotfix/#1169 extra lazy one to many should not delete referenced entities Created: 24/Jan/15  Updated: 27/Jan/15  Resolved: 25/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Lazy Loading, ORM
Affects Version/s: Git Master, 2.3.5, 2.4.7
Fix Version/s: 2.5
Security Level: All

Type: Bug Priority: Blocker
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: delete, extra-lazy, onetomany, update

Issue Links:
Dependency
depends on DDC-3544 [GH-1288] Hotfix - #1169 - extra lazy... Resolved
is required for DDC-3343 `PersistentCollection::removeElement`... Resolved

 Description   

This issue is created automatically through a Github pull request on behalf of Ocramius:

Url: https://github.com/doctrine/doctrine2/pull/1281

Message:

This is an alternate fix for #1169 (DDC-3343 http://www.doctrine-project.org/jira/browse/DDC-3343)



 Comments   
Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1169] was closed:
https://github.com/doctrine/doctrine2/pull/1169

Comment by Doctrine Bot [ 25/Jan/15 ]

A related Github Pull-Request [GH-1281] was merged:
https://github.com/doctrine/doctrine2/pull/1281





[DDC-3461] [GH-1229] Identity in onetoone association builder Created: 23/Dec/14  Updated: 26/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of guiwoda:

Url: https://github.com/doctrine/doctrine2/pull/1229

Message:



 Comments   
Comment by Doctrine Bot [ 23/Dec/14 ]

A related Github Pull-Request [GH-1229] was assigned:
https://github.com/doctrine/doctrine2/pull/1229

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1229] was labeled:
https://github.com/doctrine/doctrine2/pull/1229

Comment by Doctrine Bot [ 26/Jan/15 ]

A related Github Pull-Request [GH-1229] was unlabeled:
https://github.com/doctrine/doctrine2/pull/1229

Comment by Doctrine Bot [ 26/Jan/15 ]

A related Github Pull-Request [GH-1229] was labeled:
https://github.com/doctrine/doctrine2/pull/1229





[DDC-3452] [GH-1222] Embeddables in metadata builder Created: 17/Dec/14  Updated: 26/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of guiwoda:

Url: https://github.com/doctrine/doctrine2/pull/1222

Message:

Embeddables set the `$classMetadata->isEmbeddedClass = true` and sets `$classMetadata->isMappedSuperclass = false`, imitating the `switch` in xml / yml drivers.

Embeddeds have 2 methods, as other types have: `addEmbedded` is a one-off adder with fluent behavior, and `createEmbedded` returns an instance of `EmbeddedBuilder`. The class is very thin right now, but it's a good way to lay ground for improvements on embedded creation in the future.

This one is probably more useful than the last one, @Ocramius



 Comments   
Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1222] was labeled:
https://github.com/doctrine/doctrine2/pull/1222

Comment by Doctrine Bot [ 26/Jan/15 ]

A related Github Pull-Request [GH-1222] was labeled:
https://github.com/doctrine/doctrine2/pull/1222





[DDC-3542] [GH-1287] Typo fix Created: 25/Jan/15  Updated: 26/Jan/15  Resolved: 26/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Documentation
Affects Version/s: None
Fix Version/s: 2.5
Security Level: All

Type: Documentation Priority: Trivial
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: typo


 Description   

This issue is created automatically through a Github pull request on behalf of BenMorel:

Url: https://github.com/doctrine/doctrine2/pull/1287

Message:



 Comments   
Comment by Doctrine Bot [ 26/Jan/15 ]

A related Github Pull-Request [GH-1287] was assigned:
https://github.com/doctrine/doctrine2/pull/1287

Comment by Doctrine Bot [ 26/Jan/15 ]

A related Github Pull-Request [GH-1287] was merged:
https://github.com/doctrine/doctrine2/pull/1287





[DDC-3543] How to map and use a DB View from Doctrine2 Created: 26/Jan/15  Updated: 26/Jan/15  Resolved: 26/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Mapping Drivers, ORM
Affects Version/s: 2.4.7
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Reynier Perez Mira Assignee: Marco Pivetta
Resolution: Invalid Votes: 0
Labels: None


 Description   

I have a view on nomencladores schema called obtenerPaisesPorFabricanteProductoSolicitud. This is the content for the view:

    SELECT
    	ps.id AS psid,
    	ps.nombre,
    	fps.id AS fpsid
    FROM
    	(
    		(
    			nomencladores.pais ps
    			JOIN nomencladores.pais_fabricante_producto_solicitud pfps ON ((pfps.pais_id = ps.id))
    		)
    		JOIN negocio.fabricante_producto_solicitud fps ON (
    			(
    				pfps.fabricante_producto_solicitud_id = fps.id
    			)
    		)
    	);

I'm trying to map the view as follow:

    use Doctrine\ORM\Mapping as ORM;
    
    /**
     * @ORM\Entity
     * @ORM\Table(name="nomencladores.obtenerPaisesPorFabricanteProductoSolicitud", schema="nomencladores")
     */
    class ObtenerPaisesPorFabricanteProductoSolicitud
    {
        /**
         * @ORM\Id
         * @ORM\Column(name="psid", type="integer", nullable=false, unique=true)
         */
        protected $ps;
    
        /**
         * @ORM\Column(name="fpsid", type="integer")
         */
        protected $fps;
    
        /**
         * @ORM\Column(name="nombre", type="string")
         */
        protected $nombre;
    
        public function getPs()
        {
            return $this->ps;
        }
    
        public function getFps()
        {
            return $this->fps;
        }
    
        public function getNombre()
        {
            return $this->nombre;
        }
    }

But any time I run this code on it:

    $ent = $em->getRepository("AppBundle:ObtenerPaisesPorFabricanteProductoSolicitud")->findBy(
        array(
            "fps" => $entF->getId()
        )
    );

I got this result:

An exception occurred while executing 'SELECT t0.psid AS psid1,
t0.fpsid AS fpsid2, t0.nombre AS nombre3 FROM
nomencladores.obtenerPaisesPorFabricanteProductoSolicitud t0 WHERE
t0.fpsid = ?' with params [22]:
SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "nomencladores.obtenerpaisesporfabricanteproductosolicitud" does not
exist LINE 1: ...d1, t0.fpsid AS fpsid2, t0.nombre AS nombre3 FROM
nomenclado...

If I remove the annotations then the error transform on this:

Class "AppBundle\Entity\ObtenerPaisesPorFabricanteProductoSolicitud" is not a valid entity or mapped super class."

Why Doctrine2 or Symfony tries to execute the query instead go through the view? How I can execute the view from Symfony2/Doctrine2 side?



 Comments   
Comment by Marco Pivetta [ 26/Jan/15 ]

Nothing wrong here: the SQL generated by the ORM is correct, but your view definition is wrong: try running the select in console, manually.





[DDC-3319] Get the converted value in convertToDatabaseValueSQL() Created: 23/Sep/14  Updated: 25/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Benjamin Morel Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 1
Labels: mapping


 Description   

I have a use case where it would be useful to get the value being converted in the convertToDatabaseValueSQL() method, not just in convertToDatabaseValue().

Take the following mapping for a Geometry type:

    public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        return $value->asBinary();
    }

    public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform)
    {
        return sprintf('ST_GeomFromWkb(%s, %s)', $sqlExpr, 4326);
    }

In GIS-enabled databases, ST_GeomFromWkb() takes two parameters: the WKB binary representation of the geometry, and an integer representing the SRID (coordinate system) of the geometry, in this example the hardcoded value 4326.

I would be nice to have access to the value being converted in the convertToDatabaseValueSQL() as well, to be able to get the SRID from the geometry object itself, and replace the above code with something like:

    public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform, $value)
    {
        return sprintf('ST_GeomFromWkb(%s, %s)', $sqlExpr, $value->srid());
    }

I don't think there is currently a technical way to do this (please correct me if I'm wrong).

Could we find a BC way to pass the value being converted to the convertToDatabaseValueSQL() method to add support for this use case?



 Comments   
Comment by Michael Lucas [ 25/Jan/15 ]

The use case which you described above would be a great addition to the convertToDatabaseValueSQL() or in the convertToDatabaseValue() be able to return an array of values which could be used in the convertToDatabaseValueSQL().

    public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        return array('geometry' => $value->asBinary(), 'srid'=>$value->getSRID());
    }

    public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform)
    {
        return sprintf('ST_GeomFromWkb(%s, %s)', ':geometry', ':srid');
    }
Comment by Benjamin Morel [ 25/Jan/15 ]

Michael Lucas It's an interesting idea, it would work as well, although I think it might be much more complicated to implement!





[DDC-3406] Proxy returns string instead of object Created: 21/Nov/14  Updated: 25/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.x
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Martin Keckeis Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: orm, proxy

Issue Links:
Dependency
depends on DDC-3539 [GH-1284] #1189 DDC-3406 derived iden... Open

 Description   

I get an string in one case instead of an entity or proxy.

User -> Address -> Plant -> Hierarchy

User OneToOne Address
Address ManyToOne Plant
Plant OneToOne Hierarchy

(all are fetched as eager loading)

See PR with a test case here
https://github.com/doctrine/doctrine2/pull/1189

Reference
https://github.com/doctrine/DoctrineORMModule/issues/355



 Comments   
Comment by Doctrine Bot [ 21/Nov/14 ]

A related Github Pull-Request [GH-1189] was assigned:
https://github.com/doctrine/doctrine2/pull/1189

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1189] was labeled:
https://github.com/doctrine/doctrine2/pull/1189

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1189] was labeled:
https://github.com/doctrine/doctrine2/pull/1189

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1189] was labeled:
https://github.com/doctrine/doctrine2/pull/1189





[DDC-3539] [GH-1284] #1189 DDC-3406 derived identity in proxy must be a proxy Created: 24/Jan/15  Updated: 25/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Dependency
is required for DDC-3406 Proxy returns string instead of object Open

 Description   

This issue is created automatically through a Github pull request on behalf of Ocramius:

Url: https://github.com/doctrine/doctrine2/pull/1284

Message:

This is a horrible hack for #1189.

Not happy with it, this seems like it fixes just the symptom.



 Comments   
Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1284] was assigned:
https://github.com/doctrine/doctrine2/pull/1284

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1284] was labeled:
https://github.com/doctrine/doctrine2/pull/1284

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1189] was labeled:
https://github.com/doctrine/doctrine2/pull/1189

Comment by Doctrine Bot [ 25/Jan/15 ]

A related Github Pull-Request [GH-1284] was unlabeled:
https://github.com/doctrine/doctrine2/pull/1284

Comment by Doctrine Bot [ 25/Jan/15 ]

A related Github Pull-Request [GH-1284] was labeled:
https://github.com/doctrine/doctrine2/pull/1284





[DDC-3531] [GH-1277] [DDC-3346] Failing test for issue (bad findOneBy behaviour with eager fetch) Created: 22/Jan/15  Updated: 25/Jan/15  Resolved: 23/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Lazy Loading, ORM
Affects Version/s: Git Master, 2.4.7
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Duplicate Votes: 0
Labels: collection, eager, fetch, hydration, many-to-many, onetomany, persister

Issue Links:
Dependency
depends on DDC-3534 [GH-1280] [DDC-3346] #1277 find one w... Open
is required for DDC-3346 findOneBy returns an object with part... Resolved

 Description   

This issue is created automatically through a Github pull request on behalf of scaytrase:

Url: https://github.com/doctrine/doctrine2/pull/1277

Message:

Here is the test for DDC-3346(http://www.doctrine-project.org/jira/browse/DDC-3346) issue



 Comments   
Comment by Doctrine Bot [ 23/Jan/15 ]

A related Github Pull-Request [GH-1277] was assigned:
https://github.com/doctrine/doctrine2/pull/1277

Comment by Doctrine Bot [ 23/Jan/15 ]

A related Github Pull-Request [GH-1277] was closed:
https://github.com/doctrine/doctrine2/pull/1277

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1280] was labeled:
https://github.com/doctrine/doctrine2/pull/1280

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1277] was labeled:
https://github.com/doctrine/doctrine2/pull/1277

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1280] was assigned:
https://github.com/doctrine/doctrine2/pull/1280

Comment by Doctrine Bot [ 25/Jan/15 ]

A related Github Pull-Request [GH-1280] was merged:
https://github.com/doctrine/doctrine2/pull/1280





[DDC-3534] [GH-1280] [DDC-3346] #1277 find one with eager loads is failing Created: 23/Jan/15  Updated: 25/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: Lazy Loading, ORM
Affects Version/s: Git Master
Fix Version/s: 2.5
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Unresolved Votes: 0
Labels: collection, eager, fetch, hydrator, lazy-loading, many-to-many, onetomany, persister

Issue Links:
Dependency
is required for DDC-3346 findOneBy returns an object with part... Resolved
is required for DDC-3531 [GH-1277] [DDC-3346] Failing test for... Resolved

 Description   

This issue is created automatically through a Github pull request on behalf of Ocramius:

Url: https://github.com/doctrine/doctrine2/pull/1280

Message:

Ping @scaytrase

Note that this is a first revision and needs refactoring, so please consider helping out with that if you can.

Ping @guilhermeblanco: please check the `CachedPersisterContext` stuff: it's dirty as heck, but that's because the persister internal generated SQL caching is inconsistent as heck too.

Resolution path for 2.4.x will be to throw an exception if there is an offset or a limit.



 Comments   
Comment by Doctrine Bot [ 23/Jan/15 ]

A related Github Pull-Request [GH-1277] was assigned:
https://github.com/doctrine/doctrine2/pull/1277

Comment by Doctrine Bot [ 23/Jan/15 ]

A related Github Pull-Request [GH-1277] was closed:
https://github.com/doctrine/doctrine2/pull/1277

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1280] was labeled:
https://github.com/doctrine/doctrine2/pull/1280

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1277] was labeled:
https://github.com/doctrine/doctrine2/pull/1277

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1280] was assigned:
https://github.com/doctrine/doctrine2/pull/1280

Comment by Doctrine Bot [ 25/Jan/15 ]

A related Github Pull-Request [GH-1280] was merged:
https://github.com/doctrine/doctrine2/pull/1280





[DDC-2704] When using Discriminator EntityManager#merge fails Created: 25/Sep/13  Updated: 25/Jan/15  Resolved: 25/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.4, 2.4.2
Fix Version/s: 2.5
Security Level: All

Type: Bug Priority: Major
Reporter: Vladyslav Petrovych Assignee: Marco Pivetta
Resolution: Fixed Votes: 2
Labels: inheritance, merge, private-properties, transient-properties, unitofwork

Issue Links:
Dependency
depends on DDC-3524 [GH-1272] [DDC-2704] - merge inherite... Resolved

 Description   

I have the following hierarchy:

  • AgentConfig has relation ManyToOne with AgentTask.
  • AgentTask has DiscriminatorColumn & DiscriminatorMap assigned to it.
  • AgentTask has relation ManyToOne with AgentTaskConfig.

I believe the problem is because of the following:

UnitOfWork#doMerge has the tries to get properties the following way:

// Merge state of $entity into existing (managed) entity
foreach ($class->reflClass->getProperties() as $prop) {

This obviously doesn't get the parent class (AgentTask) properties.

Later on UnitOfWork fails on line:

$prevClass->reflFields[$assocField]->getValue($prevManagedCopy)->add($managedCopy);

because $prevManagedCopy doesn't have properties set from entity.

My proposal is to get the properties the following way:

$properties = $class->reflClass->getProperties();
$parent = $class->reflClass;
while (($parent = $parent->getParentClass()) != null) {
    $properties = array_merge($parent->getProperties(), $properties);
}

// Merge state of $entity into existing (managed) entity
foreach ($properties as $prop) {


 Comments   
Comment by Rasmus Jensen [ 20/Jan/15 ]

I have this problem as well in .
The Merge operation does not copy properties of any parent class to the managed copy. My workaround when merging entities with inheritance is:
1. Receive detached entity that is instance of a subclass.
2. fetch a managed copy of the entity from database with id of detached entity.
3. manually set properties on the managed entity.
4. flush to save changes.

This is obviously only manageable with a relatively simple datastructure, and quickly becomes very messy with more complex entities and relationship hierarchies.

Would really appreciate a fix for this

Comment by Marco Pivetta [ 20/Jan/15 ]

A temporary workaround is to change properties into protected. I'll mark this for 2.5 and see if it can be fixed by then.

Comment by Marco Pivetta [ 25/Jan/15 ]

Handled in DDC-3524





[DDC-3524] [GH-1272] [DDC-2704] - merge inherited transient properties - merge properties into uninitialized proxies Created: 20/Jan/15  Updated: 25/Jan/15  Resolved: 25/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: Git Master, 2.4.7
Fix Version/s: 2.5
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: inheritance, merge, private-properties, transient-properties, unitofwork

Issue Links:
Dependency
is required for DDC-2704 When using Discriminator EntityManage... Resolved

 Description   

This issue is created automatically through a Github pull request on behalf of Ocramius:

Url: https://github.com/doctrine/doctrine2/pull/1272

Message:

See http://www.doctrine-project.org/jira/browse/DDC-2704 - DDC-2704



 Comments   
Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1272] was unlabeled:
https://github.com/doctrine/doctrine2/pull/1272

Comment by Doctrine Bot [ 25/Jan/15 ]

A related Github Pull-Request [GH-1272] was merged:
https://github.com/doctrine/doctrine2/pull/1272





[DDC-3315] [GH-1140] [DDC-2704] merge throughout entity hierarchy Created: 19/Sep/14  Updated: 25/Jan/15  Resolved: 15/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: Git Master, 2.4.7
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Incomplete Votes: 0
Labels: inheritance, merge


 Description   

This issue is created automatically through a Github pull request on behalf of tiger-seo:

Url: https://github.com/doctrine/doctrine2/pull/1140

Message:



 Comments   
Comment by Doctrine Bot [ 15/Jan/15 ]

A related Github Pull-Request [GH-1140] was closed:
https://github.com/doctrine/doctrine2/pull/1140

Comment by Doctrine Bot [ 15/Jan/15 ]

A related Github Pull-Request [GH-1140] was assigned:
https://github.com/doctrine/doctrine2/pull/1140

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1272] was unlabeled:
https://github.com/doctrine/doctrine2/pull/1272

Comment by Doctrine Bot [ 25/Jan/15 ]

A related Github Pull-Request [GH-1272] was merged:
https://github.com/doctrine/doctrine2/pull/1272





[DDC-3541] [GH-1286] Removing XDebug from non-coverage builds Created: 25/Jan/15  Updated: 25/Jan/15  Resolved: 25/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Tools
Affects Version/s: Git Master
Fix Version/s: 2.5
Security Level: All

Type: Improvement Priority: Minor
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: build-speed, ci, travis, xdebug


 Description   

This issue is created automatically through a Github pull request on behalf of Ocramius:

Url: https://github.com/doctrine/doctrine2/pull/1286

Message:



 Comments   
Comment by Doctrine Bot [ 25/Jan/15 ]

A related Github Pull-Request [GH-1286] was assigned:
https://github.com/doctrine/doctrine2/pull/1286

Comment by Doctrine Bot [ 25/Jan/15 ]

A related Github Pull-Request [GH-1286] was labeled:
https://github.com/doctrine/doctrine2/pull/1286

Comment by Doctrine Bot [ 25/Jan/15 ]

A related Github Pull-Request [GH-1286] was labeled:
https://github.com/doctrine/doctrine2/pull/1286

Comment by Doctrine Bot [ 25/Jan/15 ]

A related Github Pull-Request [GH-1286] was merged:
https://github.com/doctrine/doctrine2/pull/1286





[DDC-3537] [GH-1282] Hotfix/#1169 extra lazy one to many should not delete referenced entities (backport to 2.4) Created: 24/Jan/15  Updated: 25/Jan/15  Resolved: 25/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Lazy Loading, ORM
Affects Version/s: 2.4.7
Fix Version/s: 2.4.8
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: delete, extra-lazy, onetomany, update

Issue Links:
Dependency
is required for DDC-3343 `PersistentCollection::removeElement`... Resolved

 Description   

This issue is created automatically through a Github pull request on behalf of Ocramius:

Url: https://github.com/doctrine/doctrine2/pull/1282

Message:

See #1169

This PR backports #1281



 Comments   
Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1282] was labeled:
https://github.com/doctrine/doctrine2/pull/1282

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1282] was assigned:
https://github.com/doctrine/doctrine2/pull/1282

Comment by Doctrine Bot [ 25/Jan/15 ]

A related Github Pull-Request [GH-1282] was merged:
https://github.com/doctrine/doctrine2/pull/1282





[DDC-3532] [GH-1278] travis: remove unnecessary database creation Created: 22/Jan/15  Updated: 25/Jan/15  Resolved: 24/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Tools
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Improvement Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Incomplete Votes: 0
Labels: ci, performance, setup, travis

Issue Links:
Reference
is referenced by DDC-3540 [GH-1285] travis: remove unnecessary ... Resolved

 Description   

This issue is created automatically through a Github pull request on behalf of TomasVotruba:

Url: https://github.com/doctrine/doctrine2/pull/1278

Message:

Ref: https://github.com/doctrine/dbal/commit/a66010640cc03e73a60cee16f1da36daabd63898

https://github.com/doctrine/doctrine2/pull/1251#discussion_r23018406



 Comments   
Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1278] was labeled:
https://github.com/doctrine/doctrine2/pull/1278

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1278] was labeled:
https://github.com/doctrine/doctrine2/pull/1278

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1278] was closed:
https://github.com/doctrine/doctrine2/pull/1278

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1278] was unlabeled:
https://github.com/doctrine/doctrine2/pull/1278

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1278] was assigned:
https://github.com/doctrine/doctrine2/pull/1278





[DDC-3538] [GH-1283] #1267 - order by broken in pagination logic (reverts #1220) Created: 24/Jan/15  Updated: 24/Jan/15  Resolved: 24/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Tools
Affects Version/s: Git Master
Fix Version/s: 2.5
Security Level: All

Type: Bug Priority: Critical
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: limitsubqueryoutputwalker, orderBy, orderby, paginator, subquery

Issue Links:
Duplicate
is duplicated by DDC-3519 [GH-1267] Failing test for an ORDER B... Resolved

 Description   

This issue is created automatically through a Github pull request on behalf of Ocramius:

Url: https://github.com/doctrine/doctrine2/pull/1283

Message:

This PR reverts #1220 and merges #1264



 Comments   
Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1283] was labeled:
https://github.com/doctrine/doctrine2/pull/1283

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1283] was merged:
https://github.com/doctrine/doctrine2/pull/1283





[DDC-3519] [GH-1267] Failing test for an ORDER BY that is INNER JOINed in a subquery Created: 19/Jan/15  Updated: 24/Jan/15  Resolved: 24/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Tools
Affects Version/s: Git Master
Fix Version/s: None
Security Level: All

Type: Bug Priority: Critical
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Duplicate Votes: 0
Labels: limit, limitsubqueryoutputwalker, orderBy, orderby, paginator, subquery

Issue Links:
Duplicate
duplicates DDC-3538 [GH-1283] #1267 - order by broken in ... Resolved

 Description   

This issue is created automatically through a Github pull request on behalf of austinsmorris:

Url: https://github.com/doctrine/doctrine2/pull/1267

Message:

A failing test case to demonstrate a problem with #1220.

cc: @Ocramius @zeroedin-bill, @mvrhov, @stof, @brianium, @mrkrstphr



 Comments   
Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1267] was labeled:
https://github.com/doctrine/doctrine2/pull/1267

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1267] was assigned:
https://github.com/doctrine/doctrine2/pull/1267

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1267] was closed:
https://github.com/doctrine/doctrine2/pull/1267





[DDC-3239] [GH-1097] `expandParameters`/`getType` in BasicEntityPersister seems to really cover just few cases Created: 01/Aug/14  Updated: 24/Jan/15  Resolved: 17/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Lazy Loading, Mapping Drivers, ORM
Affects Version/s: Git Master, 2.4.7
Fix Version/s: 2.5
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: association, composite-identifier, custom-dbal-type, identifier, persister

Issue Links:
Duplicate
duplicates DDC-3380 [GH-1178] Fixing associations using U... Resolved
Reference
is referenced by DDC-3380 [GH-1178] Fixing associations using U... Resolved

 Description   

This issue is created automatically through a Github pull request on behalf of kamazee:

Url: https://github.com/doctrine/doctrine2/pull/1097

Message:

The test case below seems fairly simple, but I believe that it might uncover a bigger issue.

It seems odd that [`getType` (and, hence, `expandParameters`)](https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php#L1731-1795) in BasicEntityPersister clearly expects field name but often gets different things.

Just set a breakpoint there and watch values through the test suite. There might be not just field name, but a column with alias as well. This works:
![screenshot from 2014-08-01 14 03 44](https://cloud.githubusercontent.com/assets/231518/3778796/c5cc3e66-1979-11e4-9279-5c322b7e8402.png)

But this, apparently, doesn't:
![screenshot from 2014-08-01 14 07 29](https://cloud.githubusercontent.com/assets/231518/3778816/20da192c-197a-11e4-90b4-4c37ee454fb6.png)

There are multiple places (more than one) that call `expandParameters` with criteria that can't be resolved with `getType`. Is this situation expected or worth further investigation/fixing?



 Comments   
Comment by Marco Pivetta [ 17/Jan/15 ]

Handled in DDC-3380

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1097] was labeled:
https://github.com/doctrine/doctrine2/pull/1097

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1097] was labeled:
https://github.com/doctrine/doctrine2/pull/1097

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1097] was assigned:
https://github.com/doctrine/doctrine2/pull/1097

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1097] was closed:
https://github.com/doctrine/doctrine2/pull/1097





[DDC-3380] [GH-1178] Fixing associations using UUIDs Created: 09/Nov/14  Updated: 24/Jan/15  Resolved: 17/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Lazy Loading, Mapping Drivers, ORM
Affects Version/s: Git Master
Fix Version/s: 2.5
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: association, composite-identifier, custom-dbal-type, identifier, persister

Issue Links:
Dependency
is required for DDC-3373 [GH-1174] Fix associations with a cus... Resolved
Duplicate
is duplicated by DDC-3239 [GH-1097] `expandParameters`/`getType... Resolved
is duplicated by DDC-3373 [GH-1174] Fix associations with a cus... Resolved
Reference
relates to DDC-3239 [GH-1097] `expandParameters`/`getType... Resolved

 Description   

This issue is created automatically through a Github pull request on behalf of jaspernbrouwer:

Url: https://github.com/doctrine/doctrine2/pull/1178

Message:

This is a port of #1174.

I was running an experiment using a custom DBAL type, which converts a UUID string (in PHP) to 16 bytes binary string (in SQL) and vice versa, as identifier for a couple of entities. I noticed some associations weren't loaded correctly. This PR attempts to fix that issue.

_Remaining issue_

There are 2 tests that involve OneToOne and OneToMany associations with composite ids of which one is a foreign one. When the owning side is fetched from the DB, a Proxy object is created for the inversed side. But this Proxy contains incorrect identifiers:

public $id => string(36) "12345678-9abc-def0-1234-56789abcdef0"
public $foreignEntity => string(16) "????????????????"

Those question-marks represent 16 bytes of binary data. The thing is that `$foreignEntity` should contain another Proxy object (or perhaps the UUID of the foreign entity, I'm not sure).

I'm at a loss here Hopefully someone can point me to where identity through foreign Entities is managed!



 Comments   
Comment by Doctrine Bot [ 09/Nov/14 ]

A related Github Pull-Request [GH-1178] was closed:
https://github.com/doctrine/doctrine2/pull/1178

Comment by Doctrine Bot [ 09/Nov/14 ]

A related Github Pull-Request [GH-1178] was reopened:
https://github.com/doctrine/doctrine2/pull/1178

Comment by Doctrine Bot [ 10/Nov/14 ]

A related Github Pull-Request [GH-1178] was assigned:
https://github.com/doctrine/doctrine2/pull/1178

Comment by Jasper N. Brouwer [ 10/Nov/14 ]

Affects Versions: master (2.5) and 2.4 are confirmed, but I suspect this goes back to all versions.

Comment by Doctrine Bot [ 17/Jan/15 ]

A related Github Pull-Request [GH-1178] was closed:
https://github.com/doctrine/doctrine2/pull/1178





[DDC-3535] Allow binding `Parameter` value object to statements, removing the need for explicit value and type passing Created: 24/Jan/15  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: Lazy Loading, ORM
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Task Priority: Critical
Reporter: Marco Pivetta Assignee: Marco Pivetta
Resolution: Unresolved Votes: 0
Labels: binding, criteria, parameters, persister, repository, type


 Comments   
Comment by Marco Pivetta [ 24/Jan/15 ]

We currently have a lot of locations in the code where we use list($values, $types) = $this->computeParameters(); (pseudo-code).

This leads to a lot of code duplication and complexity.

Maybe a Parameter VO may be used instead, or a ParameterCollection with a fixed $types and a mutable $values, and with minimal internal validation.





[DDC-3062] [GH-997] [FIX] Allow to use ManyToMany with all operators Created: 31/Mar/14  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: 2.5
Security Level: All

Type: Bug Priority: Critical
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of bakura10:

Url: https://github.com/doctrine/doctrine2/pull/997

Message:

Hi,

ping @guillhermoblanco : I think this may be blocking for 2.5

I introduced not so long ago support for ManyToMany for Criteria. However, I realized my implementation was really incomplete, because I hard-coded the "=" operator (https://github.com/doctrine/doctrine2/pull/885/files#diff-982b7374bbe9d5f4b6b71f4869a446eaR575). This means that it fails in a lot of cases when you use something different than "eq" for Criteria.

This PR fixes that, however it's a bit hacky. The SqlExpressionVisitor was made by type hinting for a BasicEntityPersister, preventing us from using us for a collection persister. Therefore I added a new interface to keep BC.

There is also a lot of code duplication (the whole "getSelectConditionSQL" was copied from the BasicEntityPersister), but without trait or BC, I have no idea about how to solve it.

All tests pass, test were added for other operators.



 Comments   
Comment by Doctrine Bot [ 13/Jan/15 ]

A related Github Pull-Request [GH-997] was assigned:
https://github.com/doctrine/doctrine2/pull/997

Comment by Doctrine Bot [ 13/Jan/15 ]

A related Github Pull-Request [GH-997] was unassigned:
https://github.com/doctrine/doctrine2/pull/997

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-997] was labeled:
https://github.com/doctrine/doctrine2/pull/997

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-997] was labeled:
https://github.com/doctrine/doctrine2/pull/997

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-997] was unlabeled:
https://github.com/doctrine/doctrine2/pull/997





[DDC-3130] [GH-1033] [WIP] Lazy criteria for ManyToMany collection Created: 18/May/14  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Reference
is referenced by DDC-2535 [GH-712] Extra lazy get for inverse s... Resolved

 Description   

This issue is created automatically through a Github pull request on behalf of bakura10:

Url: https://github.com/doctrine/doctrine2/pull/1033

Message:

This continues my previous work on making Criteria most efficient.

Currently we are wrapping matching calls on repositories and matching calls on EXTRA_LAZY associations around a LazyCriteria. However, ManyToMany are still completely loaded: https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/PersistentCollection.php#L874

This is still problematic from a performance point of view because count, contains... cannot be optimized. I think the solution is similar to previous one, hence creating a Lazy collection for that kind of associations.

However, this is really tricky to do because of the whole mess inside the persisters (can't wait for them to be completely refactored, it's getting really hard to maintain this mess ).



 Comments   
Comment by Doctrine Bot [ 13/Jan/15 ]

A related Github Pull-Request [GH-1033] was assigned:
https://github.com/doctrine/doctrine2/pull/1033

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1033] was labeled:
https://github.com/doctrine/doctrine2/pull/1033

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1033] was labeled:
https://github.com/doctrine/doctrine2/pull/1033

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1033] was unlabeled:
https://github.com/doctrine/doctrine2/pull/1033





[DDC-3529] [GH-1275] [WIP] Nullable embedded objects. Created: 21/Jan/15  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of lcobucci:

Url: https://github.com/doctrine/doctrine2/pull/1275

Message:

The idea was to have a simple (and clean) way to override the nullable property of embedded objects, so I've
added the ```nullable``` attribute on the ```@Embedded``` annotation and it have 3 possible values:

  • NULL: The nullable option that was defined on the attributes of the embeddable class won't be overriden;
  • TRUE: All attributes of the embeddable class will be marked as nullable and the embeddable instance only would be created when data is not NULL;
  • FALSE: All attributes of the embeddable class will be marked as non-nullable.

There's a lot of things to be improved (mostly on UnitOfWork), but it's fully working with basic tests as you can see on ValueObjectsTest::testCRUDOfNullableEmbedded() case.

I would appreciate a lot your opinions!



 Comments   
Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1275] was labeled:
https://github.com/doctrine/doctrine2/pull/1275

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1275] was labeled:
https://github.com/doctrine/doctrine2/pull/1275





[DDC-3528] [GH-1274] PersistentCollection now extends AbstractLazyCollection. Created: 21/Jan/15  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of guilhermeblanco:

Url: https://github.com/doctrine/doctrine2/pull/1274

Message:



 Comments   
Comment by Doctrine Bot [ 22/Jan/15 ]

A related Github Pull-Request [GH-1274] was assigned:
https://github.com/doctrine/doctrine2/pull/1274

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1274] was labeled:
https://github.com/doctrine/doctrine2/pull/1274

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1274] was labeled:
https://github.com/doctrine/doctrine2/pull/1274





[DDC-3515] [GH-1263] #1223 DDC-3453 - make `EntityManager` constructor `public` Created: 18/Jan/15  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM, Tools
Affects Version/s: None
Fix Version/s: 2.5
Security Level: All

Type: Improvement Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: constructor, entitymanager, setup

Issue Links:
Reference
is referenced by DDC-3453 [GH-1223] Refactored construction of ... Resolved

 Description   

This issue is created automatically through a Github pull request on behalf of Ocramius:

Url: https://github.com/doctrine/doctrine2/pull/1263

Message:



 Comments   
Comment by Doctrine Bot [ 18/Jan/15 ]

A related Github Pull-Request [GH-1263] was assigned:
https://github.com/doctrine/doctrine2/pull/1263

Comment by Doctrine Bot [ 18/Jan/15 ]

A related Github Pull-Request [GH-1263] was assigned:
https://github.com/doctrine/doctrine2/pull/1263

Comment by Doctrine Bot [ 18/Jan/15 ]

A related Github Pull-Request [GH-1263] was unassigned:
https://github.com/doctrine/doctrine2/pull/1263

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1263] was labeled:
https://github.com/doctrine/doctrine2/pull/1263





[DDC-3510] [GH-1261] Add a new QuoteStrategy that automatically escape database reserved keyword Created: 16/Jan/15  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of xhuberty:

Url: https://github.com/doctrine/doctrine2/pull/1261

Message:

All the upload screenshots which are used to explain what we are doing are taken from a real project developed with Mouf dependency injection framework (http://mouf-php.com/) that we use to configure the entity manager.

We wanted to create a FAQ where admin can add question/answer and use drag and drop to set the position of the question in the FAQ.

For this, at some point, in an entity, we used a protected keyword "order" in a class FAQ:

```
/**

  • @ORM\Column(type="integer", nullable=false)
  • @var int
    */
    private $order;
    ```

This fails with Doctrine. The documentation clearly explains why: http://doctrine-orm.readthedocs.org/en/latest/reference/basic-mapping.html#quoting-reserved-words

Below are a list of screenshot explaining we use the `DefaultQuoteStrategy` and the failure message we get.

![doctrineconfiguration](https://cloud.githubusercontent.com/assets/8350192/5779969/4ab5c15e-9da7-11e4-8df8-f2c718c8d66a.PNG)

In the configuration,the "quoteStrategy" setter is not set. Therefore, we use `DefaultQuoteStrategy`.

![defaultquotestrategy](https://cloud.githubusercontent.com/assets/8350192/5779977/51fe0a70-9da7-11e4-9cfa-3a86e6f8aab8.PNG)

We get this error:

![error](https://cloud.githubusercontent.com/assets/8350192/5779963/422e0bc2-9da7-11e4-902c-602a2eac7f96.PNG)
We get an error while using doctrine ORM because it doesn't auto escape protected keyword. (We can protect it manually by using ` .)

We created a new QuoteStratigy that automaticcaly escape protected keyword *only*. We just bind it via the Mouf interface:

![escapingquotestrategy](https://cloud.githubusercontent.com/assets/8350192/5780067/d9997bae-9da7-11e4-8a23-c5fa2ebaffcc.PNG)

and then the magic begins: a screenshot of the page with no error.

![succes](https://cloud.githubusercontent.com/assets/8350192/5780085/f9b597f6-9da7-11e4-85b0-cd09fb572cd9.PNG)

We would like to submit this new `EscapingQuoteStrategy` as we think it will be easier for developers to work with it, and it should not have a big performance impact (only an additional lookup in a table)



 Comments   
Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1261] was labeled:
https://github.com/doctrine/doctrine2/pull/1261

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1261] was labeled:
https://github.com/doctrine/doctrine2/pull/1261





[DDC-3507] [GH-1260] Added PersisterFactory to ORM. Created: 16/Jan/15  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of guilhermeblanco:

Url: https://github.com/doctrine/doctrine2/pull/1260

Message:



 Comments   
Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1260] was labeled:
https://github.com/doctrine/doctrine2/pull/1260

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1260] was labeled:
https://github.com/doctrine/doctrine2/pull/1260





[DDC-3481] [GH-1241] [3.0] [POC] lazy-load on a per-property base Created: 09/Jan/15  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of Ocramius:

Url: https://github.com/doctrine/doctrine2/pull/1241

Message:

This is just a proof of concept that I hacked together real quick.

This changes how proxies are generated and lazy-loaded in a very radical way:

  • method calls do not cause lazy-loading
  • lazy-loading is triggered by access to non-transient properties (things that need to be lazy-loaded)
  • access to identifiers or non-mapped properties won't cause lazy-loading

Following BC breaks need to be fixed or discussed before going forward on this idea:

  • [ ] proxies don't implement `Doctrine\Common\Proxy\Proxy` anymore, but `ProxyManager\Proxy\GhostObjectInterface` (BC break, needs fixing, can be easily done with some effort)
  • [ ] `serialize($proxy)` now causes proxy initialization (probably needs fixing, as this is a major BC break)

Pending TODOs:

  • [ ] cloning a proxy is still not fully supported (requires dedicated logic in `__clone`)
  • [ ] this is just a PoC, so the code that writes proxies to disk is not yet in place


 Comments   
Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1241] was labeled:
https://github.com/doctrine/doctrine2/pull/1241

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1241] was labeled:
https://github.com/doctrine/doctrine2/pull/1241





[DDC-3458] [GH-1228] Fixed many small phpcs issues Created: 19/Dec/14  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of acrobat:

Url: https://github.com/doctrine/doctrine2/pull/1228

Message:

This pr fixes many small phpcs issues



 Comments   
Comment by Doctrine Bot [ 19/Dec/14 ]

A related Github Pull-Request [GH-1228] was assigned:
https://github.com/doctrine/doctrine2/pull/1228

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1228] was labeled:
https://github.com/doctrine/doctrine2/pull/1228





[DDC-3455] [GH-1225] Test for RuntimeException in AnnotationExporter::exportClassMetadata() Created: 19/Dec/14  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of TorbenBr:

Url: https://github.com/doctrine/doctrine2/pull/1225

Message:



 Comments   
Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1225] was labeled:
https://github.com/doctrine/doctrine2/pull/1225

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1225] was labeled:
https://github.com/doctrine/doctrine2/pull/1225





[DDC-3446] [GH-1219] Comparison like/notlike support Created: 10/Dec/14  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of Fedik:

Url: https://github.com/doctrine/doctrine2/pull/1219

Message:

Support `Comparison::LIKE` and `Comparison::NOTLIKE` additionally to doctrine/collections#50

as alternative for #1150



 Comments   
Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1219] was labeled:
https://github.com/doctrine/doctrine2/pull/1219

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1219] was labeled:
https://github.com/doctrine/doctrine2/pull/1219





[DDC-2143] $em->refresh($entity) doesn't refresh associations cleared with clear() Created: 14/Nov/12  Updated: 24/Jan/15  Resolved: 01/May/13

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.3
Fix Version/s: None
Security Level: All

Type: Bug Priority: Critical
Reporter: Alex Assignee: Benjamin Eberlei
Resolution: Cannot Reproduce Votes: 0
Labels: None
Environment:

PHP 5.3 + APC, CentOS


Attachments: File DDC2143Test.php    
Issue Links:
Duplicate
is duplicated by DDC-1987 Cascading "refresh" does not work on ... Resolved

 Description   

  // $entity->items is m2m association

  /////////////////////
  // 1. Bug

  echo $entity->items->count(); // 2

  $entity->items->clear();

  echo $entity->items->count(); // 0

  $em->refresh($entity);

  echo $entity->items->count(); // 0 <-- ???

  //////////////////
  // 2. Workaround

  echo $entity->items->count(); // 2

  // remove items one by one

  $items = $entity->items->toArray();
  foreach ( $items as $item )
  {
    $entity->items->removeElement($item);
  }

  echo $entity->items->count(); // 0

  $em->refresh($entity);

  echo $entity->items->count(); // 2, as expected



 Comments   
Comment by Marco Pivetta [ 23/Jan/13 ]

This is because `clear` on an un-initialized collection doesn't initialize it. Can you confirm this by adding a call to

$this->initialize()

in the `clear` method of `Doctrine\ORM\PersistentCollection`?

Comment by Marco Pivetta [ 23/Jan/13 ]

Related to DDC-1987

Comment by Marco Pivetta [ 21/Feb/13 ]

Alex ping?

Comment by Benjamin Eberlei [ 31/Mar/13 ]

I cannot reproduce this issue, see the testscript attached (put into tests/Doctrine/Tests/ORM/Functional/Ticket/). Can you try to make this code fail?

Comment by Benjamin Eberlei [ 01/May/13 ]

Closed, no feedback.

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1218] was labeled:
https://github.com/doctrine/doctrine2/pull/1218





[DDC-3444] [GH-1218] Failing test case for cascading refresh Created: 09/Dec/14  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of MartijnDwars:

Url: https://github.com/doctrine/doctrine2/pull/1218

Message:



 Comments   
Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1218] was labeled:
https://github.com/doctrine/doctrine2/pull/1218





[DDC-3441] Unidirectional ManyToOne Not Lazy Loading Created: 09/Dec/14  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: Git Master, 2.4.6
Fix Version/s: None
Security Level: All

Type: Bug Priority: Critical
Reporter: Marcus Fulbright Assignee: Marco Pivetta
Resolution: Unresolved Votes: 0
Labels: lazy-loading, proxy, public-properties, reflection

Issue Links:
Dependency
depends on DDC-3442 [GH-1217] @DDC3441 failing test cases... Open

 Description   

The Unidirectional ManyToOne association described in the docs does not lazy load correctly. The appropriate SQL will get executed, and the returned Proxy does pass type hinting for the correct class. However, the lazy loaded object always has the following properties:

  • _initializer_
  • _cloner_
  • _isInitialized_
  • lazyPropertiesDefaults

Any properties from the class definition do not show up. This is problematic when trying to get reflected properties and their values. Methods are correctly reflected.

Pull request for failing test case



 Comments   
Comment by Marcus Fulbright [ 09/Dec/14 ]

Let me know if anything else is needed.

Comment by Doctrine Bot [ 11/Dec/14 ]

A related Github Pull-Request [GH-1217] was assigned:
https://github.com/doctrine/doctrine2/pull/1217

Comment by Marco Pivetta [ 11/Dec/14 ]

Looks like a current ORM limitation (private properties lazy loading).

Related:

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1217] was labeled:
https://github.com/doctrine/doctrine2/pull/1217

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1217] was labeled:
https://github.com/doctrine/doctrine2/pull/1217





[DDC-3442] [GH-1217] @DDC3441 failing test cases for the ticket Created: 09/Dec/14  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Dependency
is required for DDC-3441 Unidirectional ManyToOne Not Lazy Loa... Open

 Description   

This issue is created automatically through a Github pull request on behalf of MarcusFulbright:

Url: https://github.com/doctrine/doctrine2/pull/1217

Message:

Failing test cases for the ticket DDC-3441(http://www.doctrine-project.org/jira/browse/DDC-3441)



 Comments   
Comment by Marcus Fulbright [ 09/Dec/14 ]

I didn't realize a ticket would get automatically opened when I submitted a pull request. I already put relevant details for this in DDC-3441. This is a duplicate.

Comment by Doctrine Bot [ 11/Dec/14 ]

A related Github Pull-Request [GH-1217] was assigned:
https://github.com/doctrine/doctrine2/pull/1217

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1217] was labeled:
https://github.com/doctrine/doctrine2/pull/1217

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1217] was labeled:
https://github.com/doctrine/doctrine2/pull/1217





[DDC-3414] Joining on a table with inheritance produces badly formed ON clause Created: 26/Nov/14  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.5, 2.4.6
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Lewis Wright Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: inheritance, joins, orm, querybuilder


 Description   

When I join on a table that uses class table inheritance, Doctrine automatically joins on the parent table, but it does it before the ON clause.

So for example, writing this DQL:

SELECT uc, c FROM MyModel\Customer c LEFT JOIN MyModel\Customer uc WITH uc.customer = c

produces:

SELECT 
 # Snipped
FROM 
  customer c0_ 
  LEFT JOIN user_customer u2_ 
  INNER JOIN base_user b1_ ON u2_.id = b1_.id ON (u2_.customer_id = c0_.id)

This syntax for the ON clause looks wrong, and fails in SQLite, so I can only assume it's the result of a bug?



 Comments   
Comment by Marco Pivetta [ 26/Nov/14 ]

Please compare the DQL you wrote by hand with the one generated by the QueryBuilder

Comment by Lewis Wright [ 26/Nov/14 ]

The issue appears not to be with just the query builder, but with the DQL version too (see the updated bug report). Would it help if I made a bare-bones doctrine application demoing the problem?

Actually, what would probably be more helpful is if I added a test to the test suite for this bug. I'll see what I can do.

Comment by Marco Pivetta [ 26/Nov/14 ]

We'd need a functional test to add to the test suite, not a demo app. Sending a pull-request with a failing test case will expose the problem immediately.

Comment by Lewis Wright [ 26/Nov/14 ]

Apologies, I should have read the contribute readme first before submitting the ticket. I've created a pull request here with the failing SQLite tests:

https://github.com/doctrine/doctrine2/pull/1194

I did put this ticket number as the PR subject, but the bot seems to have created another issue here:
http://www.doctrine-project.org/jira/browse/DDC-3415

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1194] was labeled:
https://github.com/doctrine/doctrine2/pull/1194





[DDC-3415] [GH-1194] [DDC-3414] Add test for "Joining on a table with inheritance produces badly formed ON clause" Created: 26/Nov/14  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of LewisW:

Url: https://github.com/doctrine/doctrine2/pull/1194

Message:

Add a test for a bug report. The test is only simple with no assertions, since the SQL generated by Doctrine is invalid and generates an exception in SQLite.



 Comments   
Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1194] was labeled:
https://github.com/doctrine/doctrine2/pull/1194





[DDC-3390] [GH-1185] add a new method that return the mapped properties Created: 12/Nov/14  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of fabiocarneiro:

Url: https://github.com/doctrine/doctrine2/pull/1185

Message:

There are some implementations that use the doctrine metadata to get the properties of a entity (DoctrineObject), and it currently uses the getFieldNames and getAssociationNames methods to retrieve and merge it.

Since the embeddables feature was added, that method will return more than one metadata for each embeddable property, and then the hydrator can never find the appropriate setter for that property.

This method allows some implementation to retrieve all mapped fields from an entity, something that can't be done using get_class_vars for example.

Of course this implementation could be done in the hydrator, but i don't think it is its responsibility to filter and merge data received from the ClassMetadata. Since you have methods to retrieve the metadata formatted as the database structure, you should also have methods to retrieve the information to the other side, in object structure.



 Comments   
Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1185] was labeled:
https://github.com/doctrine/doctrine2/pull/1185





[DDC-3383] [GH-1179] Fix embeddables class metadata (work-in-progress) Created: 10/Nov/14  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of fabiocarneiro:

Url: https://github.com/doctrine/doctrine2/pull/1179

Message:

ClassMetadataInfo is returning more than one result in getFieldNames() for the embeddables properties. This method is used by DoctrineModule\Stdlib\Hydrator\DoctrineObject in the extraction process.

Since its returning a number of results equal the number of properties of the embedded object, it will never find the correct setter for the extraction and that causes that property to be removed from the extracted array.

I was able to solve the issue by hacking into the getFieldNames() for testing and merging the duplicated entries, and then the object was successfully extracted.

By digging into the code, i found out that there is a mapEmbedded(), but instead of using that for embeddeds, its using the default mapField, which may be the root cause of the problem.

  • [x] Hack into the getFieldNames() method to see if the expected solution would work
  • [x] Remove multiple class declaration in the same file from the files i'll work with
  • [x] Create a failing testcase
  • [ ] Create a solution


 Comments   
Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1179] was labeled:
https://github.com/doctrine/doctrine2/pull/1179

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1179] was labeled:
https://github.com/doctrine/doctrine2/pull/1179





[DDC-1952] Add support for array parameters on the SQLFilter Created: 27/Jul/12  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: Git Master
Fix Version/s: None
Security Level: All

Type: Improvement Priority: Minor
Reporter: Menno Holtkamp Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 2
Labels: None


 Description   

The SQLFilter currently only accepts string parameters which would result in SQL like:

"tableAlias.column = '$filterParameter'"

To filter an Entity that has a lifecycle, this can be usefull to filter Entities that are in a specific state, for example:

"tableAlias.state = 1"

To be able to apply the filter on an Entity that can be in multiple states, it is usefull to be able to assign an array of states using setParameter:

$allowedStates = array(1,2,3,4);
$filter->setParameter('allowedStatesParam', $allowedStates);
sprintf("tableAlias.state IN (%s)", implode(',', $this->getParameter('allowedStatesParam')));

to eventually result in:

"tableAlias.state IN (1,2,3,4)"

However, this is currently not supported, it seems to go wrong on the PDO::quote() of the parameter. The SQL works ok when setting it statically in the filter, not taking the parameter into account.

It would be nice to have support for arrays on the setParameter()



 Comments   
Comment by Petr 'PePa' Pavel [ 24/Oct/14 ]

I've just created a pull request that implements just that. The only difference is that you don't call implode on the parameter when using it.
https://github.com/doctrine/doctrine2/pull/1168

The usage would be:

$allowedStates = array(1,2,3,4);
$filter->setParameter('allowedStatesParam', $allowedStates);

$quotedList = $this->getParameter('allowedStatesParam');
"tableAlias.state IN ($quotedList)"
Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1168] was labeled:
https://github.com/doctrine/doctrine2/pull/1168





[DDC-3362] [GH-1168] [DDC-1952] Support for array parameters on the SQLFilter Created: 24/Oct/14  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of xpavp03:

Url: https://github.com/doctrine/doctrine2/pull/1168

Message:

Allows passing an array to SQLFilter parameter and have each item pass through quote() before turning the whole array into a comma-separated list.

For purpose see here:
http://www.doctrine-project.org/jira/browse/DDC-1952

Exception is made for types that Doctrine already recognizes as an array and stores as their derivate (array, simple_array, json_array).



 Comments   
Comment by Doctrine Bot [ 24/Oct/14 ]

A related Github Pull-Request [GH-1168] was assigned:
https://github.com/doctrine/doctrine2/pull/1168

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1168] was labeled:
https://github.com/doctrine/doctrine2/pull/1168





[DDC-3332] [GH-1152] Adds error message when the key is composite Created: 02/Oct/14  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of fran6co:

Url: https://github.com/doctrine/doctrine2/pull/1152

Message:

An example is:

```
SELECT u FROM User u INNER JOIN Address a ON a.user = u
```

When User has a composite key.



 Comments   
Comment by Doctrine Bot [ 02/Oct/14 ]

A related Github Pull-Request [GH-1152] was assigned:
https://github.com/doctrine/doctrine2/pull/1152

Comment by Doctrine Bot [ 17/Jan/15 ]

A related Github Pull-Request [GH-1152] was assigned:
https://github.com/doctrine/doctrine2/pull/1152

Comment by Doctrine Bot [ 17/Jan/15 ]

A related Github Pull-Request [GH-1152] was unassigned:
https://github.com/doctrine/doctrine2/pull/1152

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1152] was labeled:
https://github.com/doctrine/doctrine2/pull/1152

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1152] was labeled:
https://github.com/doctrine/doctrine2/pull/1152





[DDC-3328] [GH-1150] Improve Comparison::CONTAINS: allow to use custom position for % and _ wildcard characters Created: 28/Sep/14  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of Fedik:

Url: https://github.com/doctrine/doctrine2/pull/1150

Message:

This pull prevent forced wrapping of the value in to `%`
and allow to use the custom position for `%` and `_` wildcard characters in case `Comparison::CONTAINS`

Allow to build the `contains` expressions like:
```php
Criteria::expr()->contains('myField', 'some string%');
Criteria::expr()->contains('myField', '%some string');
Criteria::expr()->contains('myField', '10%');
Criteria::expr()->contains('myField', 's_m_ string');
```



 Comments   
Comment by Doctrine Bot [ 19/Oct/14 ]

A related Github Pull-Request [GH-1150] was assigned:
https://github.com/doctrine/doctrine2/pull/1150

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1150] was labeled:
https://github.com/doctrine/doctrine2/pull/1150





[DDC-3312] Cascade persist on non-owing side of a relation Created: 18/Sep/14  Updated: 24/Jan/15  Resolved: 18/Sep/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Asmir Mustafic Assignee: Benjamin Eberlei
Resolution: Duplicate Votes: 0
Labels: info


 Description   

Hi!
I have a strange behavior/question...

Looking to this test: https://github.com/doctrine/doctrine2/blob/master/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php#L1152

in my opinion, it may be not correct.

CmsAddress is on non-owing side of CmsUser (https://github.com/doctrine/doctrine2/blob/master/tests/Doctrine/Tests/Models/CMS/CmsUser.php#L151).

$address has the cascade persist property.

Looking at the documentation (http://doctrine-orm.readthedocs.org/en/latest/reference/unitofwork-associations.html#important-concepts) seems that changes on non-owing side of a relation are always ignored, but the testFlushAndCascadePersist supposes that persit call has to be propagate to all associations.

Where I'm wrong?

Is persist propagated to all owing and non-owing associations?

BTW, here https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/UnitOfWork.php#L2217 i can't identify anything that "skips" the non-owing side of an association.

I have also created a PR https://github.com/doctrine/doctrine2/pull/1139 that is related to my question.
I'm trying to implement the proposed PR, but I need to understand this first.



 Comments   
Comment by Asmir Mustafic [ 18/Sep/14 ]

I prefer to move this issue to https://github.com/doctrine/doctrine2/pull/1139

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1139] was labeled:
https://github.com/doctrine/doctrine2/pull/1139

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1139] was labeled:
https://github.com/doctrine/doctrine2/pull/1139





[DDC-3313] [GH-1139] Single entity flush Created: 18/Sep/14  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of goetas:

Url: https://github.com/doctrine/doctrine2/pull/1139

Message:

The current `flush` behavior seems to be inconsistent or not well documented.



 Comments   
Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1139] was labeled:
https://github.com/doctrine/doctrine2/pull/1139

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1139] was labeled:
https://github.com/doctrine/doctrine2/pull/1139





[DDC-2879] Persisting collections with Composite Primary Keys composed of 2 Foreign Keys and one metadata field Created: 31/Dec/13  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.3.4
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Dylan Johnson Assignee: Marco Pivetta
Resolution: Unresolved Votes: 0
Labels: composite, identity, mapping, orm, postgresql
Environment:

Ubuntu 13.04 and PostgresSQL 9.1.0 on Vagrant Virtual Machine running an application with Symfony2 backend and JavaScript client



 Description   

SYNOPSIS

Bug prevents persisting a collection of entities in a join table with a Composite Primary
Key made up of 2 Foreign Keys and one metadata field. From these mapping instructions:
http://docs.doctrine-project.org/en/latest/tutorials/composite-primary-keys.html#use-case-3-join-table-with-metadata

ISSUE DETAILS

SUCCESS: When FOREIGN KEY 1 is the same across items in a collection to be persisted, and FOREIGN KEY 2 is greater than FOREIGN KEY 2 in any existing PRIMARY KEY, the entity and collection are persisted correctly

    • Example: GPA "add val below" exists and has assessment value
      {"grade_point_average_id":1,"assessment_id":1,"value":4}

      We will try to add a new assessment value where assessment_id > that of any existing assessment value for GPA "add val below"

    • Request Payload:
      {"name":"Add Val Below","courses":[],"assessmentValues":[{"assessment":1,"value":4},{"assessment":3,"value":2}]}
    • Debug Log:
      [2014-01-07 11:48:01] app.INFO: START GRADE_POINT_AVERAGE_REPOSITORY #SAVE [GPA #GET_NAME =ADD VAL BELOW] [] []
      [2014-01-07 11:48:01] app.INFO:   BEGIN OUTPUT FOR GRADE POINT AVERAGE Add Val Below - ASSESSMENT VALUE 1 [] []
      [2014-01-07 11:48:01] app.INFO:         ASSESSMENT_VALUE #GET_GRADE_POINT_AVERAGE #GET_ID: 1 [] []
      [2014-01-07 11:48:01] app.INFO:         GRADE_POINT_AVERAGE #GET_ID: 1 [] []
      [2014-01-07 11:48:01] app.INFO:         ASSESSMENT_VALUE #GET_ASSESSMENT #GET_ID: 1 [] []
      [2014-01-07 11:48:01] app.INFO:         ASSESSMENT_VALUE #GET_VALUE: 4 [] []
      [2014-01-07 11:48:01] app.INFO:         MANAGED? 1 [] []
      [2014-01-07 11:48:01] app.INFO:   END OUTPUT FOR GRADE POINT AVERAGE Add Val Below - ASSESSMENT VALUE 2 [] []
      [2014-01-07 11:48:01] app.INFO:   BEGIN OUTPUT FOR GRADE POINT AVERAGE Add Val Below - ASSESSMENT VALUE 2 [] []
      [2014-01-07 11:48:01] app.INFO:         ASSESSMENT_VALUE #GET_GRADE_POINT_AVERAGE #GET_ID: 1 [] []
      [2014-01-07 11:48:01] app.INFO:         GRADE_POINT_AVERAGE #GET_ID: 1 [] []
      [2014-01-07 11:48:01] app.INFO:         ASSESSMENT_VALUE #GET_ASSESSMENT #GET_ID: 3 [] []
      [2014-01-07 11:48:01] app.INFO:         ASSESSMENT_VALUE #GET_VALUE: 2 [] []
      [2014-01-07 11:48:01] app.INFO:         MANAGED?  [] []
      [2014-01-07 11:48:01] app.INFO:   END OUTPUT FOR GRADE POINT AVERAGE Add Val Below - ASSESSMENT VALUE 3 [] []
      [2014-01-07 11:48:01] app.INFO: END GRADE_POINT_AVERAGE_REPOSITORY #SAVE [GPA #GET_NAME =ADD VAL BELOW] [] []
      [2014-01-07 11:48:01] doctrine.DEBUG: "START TRANSACTION" [] []
      [2014-01-07 11:48:01] doctrine.DEBUG: INSERT INTO gpa_assessment_value (point_value, grade_point_average_id, assessment_id) VALUES (?, ?, ?) {"1":2,"2":"1","3":"3"} []
      [2014-01-07 11:48:01] doctrine.DEBUG: UPDATE gpa_assessment_value SET point_value = ? WHERE grade_point_average_id = ? AND assessment_id = ? [4,1,1] []
      [2014-01-07 11:48:01] doctrine.DEBUG: "COMMIT" [] []

FAILURE: When FOREIGN KEY 1 is the same across items in a collection, and FOREIGN KEY 2 is less than any existing FOREIGN KEY 2, the unit of work tries to INSERT existing entity and does not operate on new entity. The EntityManager thinks it contains() the new entity, but not the old one

    • Example: GPA "add val above" exists and has assessment value
      {"assessment":3,"value":2}

      We will try to add a new assessment value where assessment_id < that of any existing assessment value for GPA "add val above"

    • Request Payload:
      {"name":"Add Val Above","courses":[],"assessmentValues":[{"assessment":1,"value":4},{"assessment":3,"value":2}]}
    • Debug log:
      [2014-01-07 11:47:09] app.INFO: START GRADE_POINT_AVERAGE_REPOSITORY #SAVE [GPA #GET_NAME =ADD VAL ABOVE] [] []
      [2014-01-07 11:47:09] app.INFO:   BEGIN OUTPUT FOR GRADE POINT AVERAGE Add Val Above - ASSESSMENT VALUE 1 [] []
      [2014-01-07 11:47:09] app.INFO:         ASSESSMENT_VALUE #GET_GRADE_POINT_AVERAGE #GET_ID: 2 [] []
      [2014-01-07 11:47:09] app.INFO:         GRADE_POINT_AVERAGE #GET_ID: 2 [] []
      [2014-01-07 11:47:09] app.INFO:         ASSESSMENT_VALUE #GET_ASSESSMENT #GET_ID: 1 [] []
      [2014-01-07 11:47:09] app.INFO:         ASSESSMENT_VALUE #GET_VALUE: 4 [] []
      [2014-01-07 11:47:09] app.INFO:         MANAGED? 1 [] []
      [2014-01-07 11:47:09] app.INFO:   END OUTPUT FOR GRADE POINT AVERAGE Add Val Above - ASSESSMENT VALUE 2 [] []
      [2014-01-07 11:47:09] app.INFO:   BEGIN OUTPUT FOR GRADE POINT AVERAGE Add Val Above - ASSESSMENT VALUE 2 [] []
      [2014-01-07 11:47:09] app.INFO:         ASSESSMENT_VALUE #GET_GRADE_POINT_AVERAGE #GET_ID: 2 [] []
      [2014-01-07 11:47:09] app.INFO:         GRADE_POINT_AVERAGE #GET_ID: 2 [] []
      [2014-01-07 11:47:09] app.INFO:         ASSESSMENT_VALUE #GET_ASSESSMENT #GET_ID: 3 [] []
      [2014-01-07 11:47:09] app.INFO:         ASSESSMENT_VALUE #GET_VALUE: 2 [] []
      [2014-01-07 11:47:09] app.INFO:         MANAGED?  [] []
      [2014-01-07 11:47:09] app.INFO:   END OUTPUT FOR GRADE POINT AVERAGE Add Val Above - ASSESSMENT VALUE 3 [] []
      [2014-01-07 11:47:09] app.INFO: END GRADE_POINT_AVERAGE_REPOSITORY #SAVE [GPA #GET_NAME =ADD VAL ABOVE] [] []
      [2014-01-07 11:47:09] doctrine.DEBUG: "START TRANSACTION" [] []
      [2014-01-07 11:47:09] doctrine.DEBUG: INSERT INTO gpa_assessment_value (point_value, grade_point_average_id, assessment_id) VALUES (?, ?, ?) {"1":2,"2":"2","3":"3"} []
      [2014-01-07 11:47:09] doctrine.DEBUG: "ROLLBACK" [] []
      [2014-01-07 11:47:09] event.DEBUG: Notified event "kernel.exception" to listener "Symfony\Component\Security\Http\Firewall\ExceptionListener::onKernelException". [] []
      [2014-01-07 11:47:09] event.DEBUG: Notified event "kernel.exception" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelException". [] []
      [2014-01-07 11:47:09] event.DEBUG: Notified event "kernel.exception" to listener "Symfony\Component\HttpKernel\EventListener\ExceptionListener::onKernelException". [] []
      [2014-01-07 11:47:09] request.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\DBALException: "An exception occurred while executing 'INSERT INTO gpa_assessment_value (point_value, grade_point_average_id, assessment_id) VALUES (?, ?, ?)' with params [2, "2", "3"]:
      
      SQLSTATE[23505]: Unique violation: 7 ERROR:  duplicate key value violates unique constraint "gpa_assessment_value_pkey"
      DETAIL:  Key (grade_point_average_id, assessment_id)=(2, 3) already exists." at /vagrant/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php line 47 {"exception":"[object] (Doctrine\\DBAL\\DBALException: An exception occurred while executing 'INSERT INTO gpa_assessment_value (point_value, grade_point_average_id, assessment_id) VALUES (?, ?, ?)' with params [2, \"2\", \"3\"]:\n\nSQLSTATE[23505]: Unique violation: 7 ERROR:  duplicate key value violates unique constraint \"gpa_assessment_value_pkey\"\nDETAIL:  Key (grade_point_average_id, assessment_id)=(2, 3) already exists. at /vagrant/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:47, PDOException: SQLSTATE[23505]: Unique violation: 7 ERROR:  duplicate key value violates unique constraint \"gpa_assessment_value_pkey\"\nDETAIL:  Key (grade_point_average_id, assessment_id)=(2, 3) already exists. at /vagrant/vendor/doctrine/dbal/lib/Doctrine/DBAL/Statement.php:138)"} []
         

CODE

migration.sql
CREATE TABLE assessment
(
    id       bigserial NOT NULL,
    scale_id bigint    NOT NULL,
    title    varchar   NOT NULL,
    passing  boolean   NOT NULL,
    rank     int,

    PRIMARY KEY (id)
);

CREATE TABLE assessment_scale
(
    id   bigserial NOT NULL,
    name varchar   NOT NULL,

    PRIMARY KEY (id)
);

-- ...

CREATE TABLE grade_point_average
(
    id                         bigserial       NOT NULL,
    name                       varchar         NOT NULL,
    additional_credit_allowance numeric(4, 2),

    PRIMARY KEY (id)
);

-- ...

CREATE TABLE gpa_assessment_value
(
    grade_point_average_id bigint        NOT NULL,
    assessment_id          bigint        NOT NULL,
    point_value            numeric(4, 2) NOT NULL,

    PRIMARY KEY (assessment_id, grade_point_average_id),
    FOREIGN KEY (assessment_id) REFERENCES assessment,
    FOREIGN KEY (grade_point_average_id) REFERENCES grade_point_average
);
GradePointAverage.php
<?php
namespace LGSConnect\Model;

use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\Column;
//...
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
use LGSConnect\Util\ConstructorArgs;
use LGSConnect\Model\GradePointAverage\AssessmentValue;
// ...

/**
 * @Entity("LGSConnect\Repository\GradePointAverageRepository")
 */
class GradePointAverage
{
    // GradePointAverage Model (owning side): a tool for evaluating a student's performance 
    // by dividing the total points earned by total credits attempted.

    use ConstructorArgs;

    /**
     * @Id
     * @GeneratedValue
     * @Column(type="bigint")
     *
     * @var int
     */
    private $id;

    // ...

    /**
     * @OneToMany(targetEntity="LGSConnect\Model\GradePointAverage\AssessmentValue", mappedBy="gradePointAverage", cascade="persist")
     *
     * @var Collection
     */
    private $assessmentValues;
    
    // ...

    /**
     * @param array $args
     */
    public function __construct(array $args = [])
    {
        $this->assessmentValues = new ArrayCollection;
        // ...
        $this->handleArgs($args);
    }
    
    // ...
    
    /**
     * @return Collection
     */
    public function getAssessmentValues()
    {
        return $this->assessmentValues;
    }

    /**
     * @param ArrayCollection $assessmentValues
     */
    public function setAssessmentValues(ArrayCollection $assessmentValues)
    {
        $this->assessmentValues = $assessmentValues;
    }

    /**
     * @param AssessmentValue $assessmentValue
     */
    public function addAssessmentValue(AssessmentValue $assessmentValue)
    {
        $this->assessmentValues->add($assessmentValue);
    }

    /**
     * @param AssessmentValue $assessmentValue
     */
    public function removeAssessmentValue(AssessmentValue $assessmentValue)
    {
        $this->assessmentValues->removeElement($assessmentValue);
    }
    
    // ...
}
AssessmentValue.php
<?php
namespace LGSConnect\Model\GradePointAverage;

use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Table;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\JoinColumn;
use LGSConnect\Model\GradePointAverage;
use LGSConnect\Model\Assessment;
use LGSConnect\Util\ConstructorArgs;

/**
 * @Entity("LGSConnect\Repository\GradePointAverage\AssessmentValueRepository")
 * @Table("gpa_assessment_value")
 */
class AssessmentValue
{
    // AssessmentValue Model (inverse side): a number of points assigned 
    // to an Assessment by a Grade Point Average

    use ConstructorArgs;

    /**
     * @Id
     * @ManyToOne(targetEntity="LGSConnect\Model\GradePointAverage")
     */
    private $gradePointAverage;

    /**
     * @Id
     * @ManyToOne(targetEntity="LGSConnect\Model\Assessment")
     */
    private $assessment;

    /**
     * @Column("point_value")
     *
     * @var float
     */
    private $value;

    /**
     * @param array $args
     */
    public function __construct(array $args = [])
    {
        $this->handleArgs($args);
    }

    /**
     * @return GradePointAverage
     */
    public function getGradePointAverage()
    {
        return $this->gradePointAverage;
    }

    /**
     * @param GradePointAverage $gradePointAverage
     */
    public function setGradePointAverage(GradePointAverage $gradePointAverage)
    {
        $this->gradePointAverage = $gradePointAverage;
    }

    /**
     * @return Assessment
     */
    public function getAssessment()
    {
        return $this->assessment;
    }

    /**
     * @param Assessment $assessment
     */
    public function setAssessment(Assessment $assessment)
    {
        $this->assessment = $assessment;
    }

    /**
     * @return float
     */
    public function getValue()
    {
        return $this->value;
    }

    /**
     * @param float $value
     */
    public function setValue($value)
    {
        $this->value = $value;
    }

    /**
     * @return AssessmentScale
     */
    public function getAssessmentScale()
    {
        return $this->assessment->getScale();
    }
}
Assessment.php
<?php
namespace LGSConnect\Model;

use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\ManyToOne;
use LGSConnect\Model\Assessment\Scale;
use LGSConnect\Util\ConstructorArgs;

/**
 * @Entity("LGSConnect\Repository\AssessmentRepository")
 */
class Assessment
{
    // Assessment (related, but unmapped): A "grade" assigned to a student 
    // for attending a course section

    use ConstructorArgs;

    /**
     * @Id
     * @GeneratedValue
     * @Column(type="bigint")
     *
     * @var int
     */
    private $id;
    
    // ...

    /**
     * @param array $args
     */
    public function __construct(array $args = [])
    {
        $this->handleArgs($args);
    }

    /**
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }
    
    // ...
}
GradePointAverageRepository.php
<?php
namespace LGSConnect\Repository;

use Doctrine\ORM\EntityRepository;
// ...
use LGSConnect\Model\GradePointAverage;

class GradePointAverageRepository extends BaseRepository implements GradePointAverageRepositoryInterface
{
    // ...

    /**
     * @param GradePointAverage $gradePointAverage
     */
    public function save(GradePointAverage $gradePointAverage)
    {
        $this->getEntityManager()->persist($gradePointAverage);
        $this->getEntityManager()->flush();
    }
}
AssessmentValueRepository.php
<?php
namespace LGSConnect\Repository\GradePointAverage;

use Doctrine\ORM\EntityRepository;
use LGSConnect\Model\GradePointAverage\AssessmentValue;

class AssessmentValueRepository extends EntityRepository
{
    /**
     * @param AssessmentValue $assessmentValue
     */
    public function save(AssessmentValue $assessmentValue)
    {
        $this->getEntityManager()->persist($assessmentValue);
        $this->getEntityManager()->flush();
    }
}
GradePointAverageManager.php
<?php
namespace LGSConnect\Manager;

use InvalidArgumentException;
use Symfony\Component\Validator\ValidatorInterface;
use JMS\DiExtraBundle\Annotation\Service;
use JMS\DiExtraBundle\Annotation\InjectParams;
use JMS\SecurityExtraBundle\Annotation\PreAuthorize;
use Knp\Component\Pager\Pagination\PaginationInterface;
use LGSConnect\Repository\GradePointAverageRepository;
use LGSConnect\PaginationFactory\GradePointAveragePaginationFactoryInterface;
use LGSConnect\Model\GradePointAverage;

/**
 * @Service("grade_point_average_manager")
 */
class GradePointAverageManager
{
    /**
     * @var GradePointAverageRepository
     */
    private $gradePointAverageRepository;

    /**
     * @var GradePointAveragePaginationFactoryInterface
     */
    private $gradePointAveragePaginationFactory;

    /**
     * @var ValidatorInterface
     */
    private $validator;

    /**
     * @InjectParams
     *
     * @param GradePointAverageRepository $gradePointAverageRepository
     * @param GradePointAveragePaginationFactoryInterface $gradePointAveragePaginationFactory
     * @param ValidatorInterface $validator
     */
    public function __construct(
        GradePointAverageRepository $gradePointAverageRepository,
        GradePointAveragePaginationFactoryInterface $gradePointAveragePaginationFactory,
        ValidatorInterface $validator
    )
    {
        $this->gradePointAverageRepository = $gradePointAverageRepository;
        $this->gradePointAveragePaginationFactory = $gradePointAveragePaginationFactory;
        $this->validator = $validator;
    }

    /**
     * @PreAuthorize("isAllowedToManageTheGradePointAverage(#gradePointAverage)")
     * @param GradePointAverage $gradePointAverage
     * @throws InvalidArgumentException
     */
    public function save(GradePointAverage $gradePointAverage)
    {
        $violationList = $this->validator->validate($gradePointAverage);
        if ($violationList->count()) {
            throw new InvalidArgumentException;
        }

        $this->gradePointAverageRepository->save($gradePointAverage);
    }
}
GradePointAverageController.php
<?php
namespace LGSConnect\Controller;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Doctrine\Common\Collections\ArrayCollection;
use FOS\RestBundle\View\View;
use JMS\DiExtraBundle\Annotation\Service;
use JMS\DiExtraBundle\Annotation\InjectParams;
use JMS\SecurityExtraBundle\Annotation\PreAuthorize;
use Knp\Component\Pager\Pagination\PaginationInterface;
use LGSConnect\Manager\GradePointAverageManager;
use LGSConnect\Model\GradePointAverage;
use LGSConnect\Model\GradePointAverage\AssessmentValue;

/**
 * @Service("grade_point_average_controller", parent="lgs.controller.abstract")
 * @Route("/gpa", service="grade_point_average_controller")
 */
class GradePointAverageController extends BaseController
{
    /**
     * @var GradePointAverageManager
     */
    private $gradePointAverageManager;

    private $logger;

    /**
     * @InjectParams
     *
     * @param GradePointAverageManager $gradePointAverageManager
     * @param LoggerInterface $logger
     */
    public function __construct(GradePointAverageManager $gradePointAverageManager, LoggerInterface $logger)
    {
        $this->gradePointAverageManager = $gradePointAverageManager;
        $this->logger = $logger;
    }
    
    // ...

    /**
     * @Route("/{id}", name="gpa.edit", requirements={"id" = "\d+"})
     * @Method("PUT")
     *
     * @param Request $request
     * @param GradePointAverage $gpa
     * @return View
     */
    public function editAction(Request $request, GradePointAverage $gpa)
    {
        $form = $this->formFactory->createNamed(null, 'gpa', $gpa, [
            'method' => 'PUT',
        ]);
        $form->handleRequest($request);

        foreach ($gpa->getAssessmentValues() as $av) {
            $this->logger->info('GPA ID PREVALIDATE IN CONTROLLER:'.$gpa->getId());
            $this->logger->info('PREVALIDATE IN CONTROLLER ASSESSMENT VAL ASSESSMENT ID:'.$av->getAssessment()->getId());
            $this->logger->info('PREVALIDATE IN CONTROLLER ASSESSMENT VAL POINTS:'.$av->getValue());
        }

        /*
        // try reversing the order of the collection to see if that helps
        $assessmentVals = $gpa->getAssessmentValues()->toArray();
        $reversed = array_reverse($assessmentVals);
        $reversedColl = new ArrayCollection($reversed);
        $gpa->setAssessmentValues($reversedColl);
        */

        if ($form->isValid()) {
            foreach ($gpa->getAssessmentValues() as $av) {
                $this->logger->info('GPA ID PRESAVE IN CONTROLLER:'.$gpa->getId());
                $this->logger->info('PRESAVE IN CONTROLLER ASSESSMENT VAL ASSESSMENT ID:'.$av->getAssessment()->getId());
                $this->logger->info('PRESAVE IN CONTROLLER ASSESSMENT VAL POINTS:'.$av->getValue());
            }
            $this->gradePointAverageManager->save($gpa);

            return new View($gpa, 204);
        }

        return new View($form);
    }

    // ...
}
GradePointAverageType.php
<?php
namespace LGSConnect\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use JMS\DiExtraBundle\Annotation\FormType;

/**
 * @FormType
 */
class GradePointAverageType extends AbstractType
{
    /**
     * @param FormBuilderInterface $builder
     * @param array $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('name')
            ->add('courses', 'entity', [
                'class' => 'Model:Course',
                'multiple' => true
            ])
            ->add('assessmentValues', 'collection', [
                'type' => 'gpa_assessment_value',
                'allow_add' => true,
                'by_reference' => false,
            ])
        ;
    }

    /**
     * @return string
     */
    public function getName()
    {
        return 'gpa';
    }
}
AssessmentValueType.php
<?php
namespace LGSConnect\Form\Type\GradePointAverage;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use JMS\DiExtraBundle\Annotation\FormType;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

/**
 * @FormType("gpa_assessment_value")
 */
class AssessmentValueType extends AbstractType
{
    /**
     * @param FormBuilderInterface $builder
     * @param array $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('assessment', 'entity', [
                'class' => 'Model:Assessment',
            ])
            ->add('value', 'number', [
                'precision' => 2,
            ])
        ;
    }

    /**
     * @param OptionsResolverInterface $resolver
     */
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults([
            'data_class' => 'LGSConnect\Model\GradePointAverage\AssessmentValue',
        ]);
    }

    /**
     * @return string
     */
    public function getName()
    {
        return 'gpa_assessment_value';
    }
}


 Comments   
Comment by Valentin Nazarov [ 23/Jan/15 ]

Any update on this issue? We've got same problem in our project (PostgreSQL 9.4, Doctrine 2.4.7)

Comment by Marco Pivetta [ 24/Jan/15 ]

Removed the "feedback required" flag.

Valentin Nazarov if there is no ticket update, well... then there is no actual update.

Somewhat related to https://github.com/doctrine/doctrine2/pull/1113

I suggest getting your hands dirty and fixing it yourself if it affects you.

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1113] was labeled:
https://github.com/doctrine/doctrine2/pull/1113

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1113] was labeled:
https://github.com/doctrine/doctrine2/pull/1113





[DDC-3258] [GH-1113] Added support for composite primary key on findBy methods and Criteria Created: 18/Aug/14  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Improvement Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Duplicate
is duplicated by DDC-3260 [GH-1114] Composite pk break test Resolved
is duplicated by DDC-3316 [GH-1141] Always allow proxies on ToO... Resolved

 Description   

This issue is created automatically through a Github pull request on behalf of goetas:

Url: https://github.com/doctrine/doctrine2/pull/1113

Message:

Hi!
I tried to implement the matching of entities that uses composite primary keys...

Any suggestion?



 Comments   
Comment by Doctrine Bot [ 22/Oct/14 ]

A related Github Pull-Request [GH-1113] was assigned:
https://github.com/doctrine/doctrine2/pull/1113

Comment by Doctrine Bot [ 18/Jan/15 ]

A related Github Pull-Request [GH-1113] was closed:
https://github.com/doctrine/doctrine2/pull/1113

Comment by Doctrine Bot [ 18/Jan/15 ]

A related Github Pull-Request [GH-1113] was reopened:
https://github.com/doctrine/doctrine2/pull/1113

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1113] was labeled:
https://github.com/doctrine/doctrine2/pull/1113

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1113] was labeled:
https://github.com/doctrine/doctrine2/pull/1113





[DDC-3259] Second level & UnitOfWork inconsistencies Created: 19/Aug/14  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Improvement Priority: Major
Reporter: Asmir Mustafic Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: second-level-cache


 Description   

Hi!

I have a lot of entities with entity associations as keys and I'm trying to use second level cache.

Looking at the method: UnitOfWork::createEntity($className, array $data, &$hints = array())

  • $className: contains the class name
  • $data: contains the raw data (the row coming from the database)

Enabling the second level cache, DefaultQueryCache::get calls the createEntity method passing a $data that contains object entities and some raw data (https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Cache/DefaultQueryCache.php#L155).

I think that DefaultQueryCache should not introduce a variant of $data and should create a compatible version of $data.



 Comments   
Comment by Marco Pivetta [ 19/Aug/14 ]

Asmir Mustafic do you have any example of where this may be happening?

Comment by Asmir Mustafic [ 19/Aug/14 ]

https://github.com/doctrine/doctrine2/pull/1114

This is the same branch of https://github.com/doctrine/doctrine2/pull/1113, plus this commit (https://github.com/goetas/doctrine2/commit/bfbbb9123fd28f7fa053b76895eaa77e00095aa6) that simply involves the second level cache too.
Travis should fail soon.

Comment by Doctrine Bot [ 19/Aug/14 ]

A related Github Pull-Request [GH-1114] was closed:
https://github.com/doctrine/doctrine2/pull/1114

Comment by Asmir Mustafic [ 19/Aug/14 ]

Here the failure https://travis-ci.org/doctrine/doctrine2/jobs/32972996#L402

Comment by Doctrine Bot [ 22/Oct/14 ]

A related Github Pull-Request [GH-1113] was assigned:
https://github.com/doctrine/doctrine2/pull/1113

Comment by Doctrine Bot [ 18/Jan/15 ]

A related Github Pull-Request [GH-1113] was closed:
https://github.com/doctrine/doctrine2/pull/1113

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1113] was labeled:
https://github.com/doctrine/doctrine2/pull/1113

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1113] was labeled:
https://github.com/doctrine/doctrine2/pull/1113





[DDC-3200] [GH-1077] Support filter parameters in Configuration Created: 01/Jul/14  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of jmikola:

Url: https://github.com/doctrine/doctrine2/pull/1077

Message:

Based on work done in doctrine/mongodb-odm#908

My understanding is that this makes it easier to setup filters at boot time, instead of having to fetch them from the collection later on.

For added context, the related PR from MongoDB ODM's Symfony bundle is doctrine/DoctrineMongoDBBundle#255



 Comments   
Comment by Doctrine Bot [ 11/Nov/14 ]

A related Github Pull-Request [GH-1077] was assigned:
https://github.com/doctrine/doctrine2/pull/1077

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1077] was labeled:
https://github.com/doctrine/doctrine2/pull/1077





[DDC-3044] [GH-986] Add last modified time for metadata Created: 22/Mar/14  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Improvement Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of c960657:

Url: https://github.com/doctrine/doctrine2/pull/986

Message:

This patch improves performance during development and does not affect production performance.

Currently, enabling the metadata cache during development gives a remarkable performance boost, but it requires that you manually flush the metadata cache when the metadata has been changed. When running console commands such as ``console orm:schema-tool:update`` (see #979).

With this change, metadata entries fetched from cache are checked for freshness using a quick last modified check. This is much faster than loading the actual metadata using the metadata driver. This allows you to enable the metadata cache during development without the need for manually flushing the metadata cache.

This PR is part 1 of 2. Part 2 is for the doctrine/common repository.

If this PR is accepted, it allows us to optimize the auto-generate proxy classes feature by comparing the last modified time for the metadata with the modified timestamp of the generated file.



 Comments   
Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-986] was labeled:
https://github.com/doctrine/doctrine2/pull/986





[DDC-2973] [GH-949] Add a default lock mode to the EntityManager Created: 10/Feb/14  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of BenMorel:

Url: https://github.com/doctrine/doctrine2/pull/949

Message:

Following [this discussion](https://groups.google.com/forum/#!topic/doctrine-dev/xKGzQcDkilE) on the mailing list, this is a first draft of a proposal to introduce a default lock mode for all entities loaded through an EntityManager.

At the moment, there is no way to set a lock mode for the following use cases:

  • Proxies obtained through `getReference()` and then initialized
  • Entities lazy-loaded through traversal of associations

This proposal introduces the idea of a default lock mode, which can be set at runtime when all reads in a transaction should be locking.

It works this way:

$em->beginTransaction();
$em->getConfiguration()->setDefaultLockMode(LockMode::PESSIMISTIC_WRITE);

// load entities from EntityManager, Repositories or DQL, traverse associations, etc.
// all these entities will be loaded with the given lock mode

$em->commit();
$em->getConfiguration()->setDefaultLockMode(null);

I have successfully tested it with the following use cases:

  • `EntityManager::find()`
  • `EntityRepository::findBy()`
  • DQL queries
  • Proxies
  • Lazy-loaded collections through OneToMany and ManyToMany associations

Before moving forward and writing proper unit tests, I'm looking for your feedback on this proposal. Is this a concept you would be happy to integrate in Doctrine?

If yes, I have a doubt as regards to where the default lock mode should be set: @Ocramius suggested to set it on the `Configuration`; this looked reasonable at first glance, and I have implemented it this way for now. It feels a tiny bit wrong though now that I see it, as I feel like the contents of the Configuration should should only be set during bootstrapping, rather than being set and reset in the controllers as in the example above. I might be wrong obviously.

My suggestion would be to move the default lock mode to the EntityManager, so that the code would become:

$em->beginTransaction();
$em->setDefaultLockMode(LockMode::PESSIMISTIC_WRITE);

Happily waiting for your feedback!



 Comments   
Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-949] was labeled:
https://github.com/doctrine/doctrine2/pull/949

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-949] was labeled:
https://github.com/doctrine/doctrine2/pull/949





[DDC-2940] [GH-922] Two hooks for DoctrineBundle to allow ContainerFilterCollection Created: 29/Jan/14  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of nicoschoenmaker:

Url: https://github.com/doctrine/doctrine2/pull/922

Message:

Allows the DoctrineBundle to inject a ```ContainerFilterCollection``` that creates filters through dependency injection. See doctrine/DoctrineBundle#245.

Would prefer to inject the ```FilterCollection``` into the constructor of the em, but since they have a cyclic dependency I chose setter injection.



 Comments   
Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-922] was labeled:
https://github.com/doctrine/doctrine2/pull/922

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-922] was labeled:
https://github.com/doctrine/doctrine2/pull/922





[DDC-2785] spl_object_hash_collisions Created: 08/Nov/13  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: Git Master
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: flack Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Ubuntu 12.04



 Description   

After reading DDC-1896 and DDC-136, I'm not exactly sure if this qualifies as a bug, but anyways, here's my code to reproduce:

    public function test_hash_collision()
    {
        $counter = 0;
        do
        {
            $object = $this->create_object();
            $counter++;
            if ($counter > 1000)
            {
                //mark as skipped ? (I never hit this on PHP 5.3 at least)
                break;
            }
        }
        while ($object === false);

        // This fails with "Failed asserting that 1 matches expected 2."
        $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($object));
    }

    private function create_object()
    {
        static $hashes = array();
        $phone = new CmsPhonenumber();
        $phone->phonenumber = "1234";
        $hash = spl_object_hash($phone);
        $this->_em->persist($phone);

        if (!array_key_exists($hash, $hashes))
        {
            $hashes[$hash] = true;
            $this->_em->flush($phone);
            $this->_em->remove($phone);
            $this->_em->flush($phone);
            return false;
        }
        // Bingo! We have a new object with a recycled hash
        return $phone;
    }


 Comments   
Comment by Marco Pivetta [ 08/Nov/13 ]

Are you able to reproduce the test also without statics?

Comment by flack [ 08/Nov/13 ]

Yes, if I switch to $this->hashes (private $hashes = array()), the result is the same

Comment by flack [ 08/Nov/13 ]

Here's the complete test without statics & according to Doctrine CS (AFAICT):

<?php

namespace Doctrine\Tests\ORM\Functional\Ticket;

use Doctrine\Tests\Models\CMS\CmsPhonenumber;

require_once __DIR__ . '/../../../TestInit.php';

/**
 * @group DDC-2785
 */
class DDC2785Test extends \Doctrine\Tests\OrmFunctionalTestCase
{
    public function setUp()
    {
        $this->useModelSet('cms');
        parent::setUp();
    }

    private $hashes = array();

    public function testIssue()
    {
        $counter = 0;
        do
        {
            $object = $this->createObject();
            $counter++;
            if ($counter > 1000)
            {
                //mark as skipped ? (I never hit this on PHP 5.3 at least)
                break;
            }
        }
        while ($object === false);

        $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($object));
    }

    private function createObject()
    {
        $phone = new CmsPhonenumber();
        $phone->phonenumber = "1234";
        $hash = spl_object_hash($phone);
        $this->_em->persist($phone);

        if (!array_key_exists($hash, $this->hashes))
        {
            $this->hashes[$hash] = true;
            $this->_em->flush();
            $this->_em->remove($phone);
            $this->_em->flush();
            return false;
        }

        return $phone;
    }
}

I can try and send this as a pull request, if it helps

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-843] was labeled:
https://github.com/doctrine/doctrine2/pull/843





[DDC-2786] [GH-843] Add failing test for DDC-2785 Created: 08/Nov/13  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of flack:

Url: https://github.com/doctrine/doctrine2/pull/843

Message:

Add a failing test for

http://www.doctrine-project.org/jira/browse/DDC-2785



 Comments   
Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-843] was labeled:
https://github.com/doctrine/doctrine2/pull/843





[DDC-2584] [GH-743] Added coverage to DDC-2524. Updated DDC-1719 to fix related DBAL bug. Created: 31/Jul/13  Updated: 24/Jan/15  Resolved: 08/Aug/13

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: 2.5
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of guilhermeblanco:

Url: https://github.com/doctrine/doctrine2/pull/743

Message:



 Comments   
Comment by Doctrine Bot [ 31/Jul/13 ]

A related Github Pull-Request [GH-743] was closed:
https://github.com/doctrine/doctrine2/pull/743

Comment by Fabio B. Silva [ 08/Aug/13 ]

Merged, For more details see : https://github.com/doctrine/doctrine2/pull/743

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-707] was labeled:
https://github.com/doctrine/doctrine2/pull/707





[DDC-2524] Wrong commit order with cascade remove and double association Created: 24/Jun/13  Updated: 24/Jan/15

Status: Reopened
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Matthieu Napoli Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 2
Labels: None


 Description   

We have stumbled upon a bug in a situation where a class A has the following associations to a class B:

  • A has one B (oneToOne unidirectional)
  • A has many B (oneToMany bidirectional)

Associations are with cascade remove.

We will submit a PR soon with a failing test case.

The failure is a MySQL foreign key violation exception when removing A (removals for B are executed after removals for A).



 Comments   
Comment by Valentin Claras [ 24/Jun/13 ]

Here a link to the pull request https://github.com/doctrine/doctrine2/pull/707

Comment by Matthieu Napoli [ 25/Jun/13 ]

The tests on Travis are failing as expected.

https://travis-ci.org/doctrine/doctrine2/builds/8382962

Here is the list of the queries executed for MySQL:

SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`doctrine_tests`.`CascadeRemoveOrderEntityG`, CONSTRAINT `FK_23681E8F99938CE5` FOREIGN KEY (`ownerO_id`) REFERENCES `CascadeRemoveOrderEntityO` (`id`))

With queries:

13. SQL: 'DELETE FROM CascadeRemoveOrderEntityO WHERE id = ?' Params: '1'
12. SQL: '"START TRANSACTION"' Params: 
11. SQL: 'SELECT t0.id AS id1, t0.ownerO_id AS ownerO_id2 FROM CascadeRemoveOrderEntityG t0 WHERE t0.ownerO_id = ?' Params: '1'
10. SQL: 'SELECT t0.id AS id1, t0.oneToOneG_id AS oneToOneG_id2 FROM CascadeRemoveOrderEntityO t0 WHERE t0.id = ?' Params: '1'
9. SQL: '"COMMIT"' Params: 
8. SQL: 'INSERT INTO CascadeRemoveOrderEntityG (ownerO_id) VALUES (?)' Params: '1'
7. SQL: 'INSERT INTO CascadeRemoveOrderEntityO (oneToOneG_id) VALUES (?)' Params: ''
6. SQL: '"START TRANSACTION"' Params: 

As you can see, the latest query causes a foreign key constraint violation (wrong order with the next, non-executed query).

Comment by Matthieu Napoli [ 25/Jun/13 ]

On the sqlite tests we can see better the order the queries are executed:

14. SQL: 'DELETE FROM CascadeRemoveOrderEntityG WHERE id = ?' Params: '1'
13. SQL: 'DELETE FROM CascadeRemoveOrderEntityO WHERE id = ?' Params: '1'
12. SQL: '"START TRANSACTION"' Params: 
11. SQL: 'SELECT t0.id AS id1, t0.ownerO_id AS ownerO_id2 FROM CascadeRemoveOrderEntityG t0 WHERE t0.ownerO_id = ?' Params: '1'
10. SQL: 'SELECT t0.id AS id1, t0.oneToOneG_id AS oneToOneG_id2 FROM CascadeRemoveOrderEntityO t0 WHERE t0.id = ?' Params: '1'
9. SQL: '"COMMIT"' Params: 
8. SQL: 'INSERT INTO CascadeRemoveOrderEntityG (ownerO_id) VALUES (?)' Params: '1'
7. SQL: 'INSERT INTO CascadeRemoveOrderEntityO (oneToOneG_id) VALUES (?)' Params: ''
6. SQL: '"START TRANSACTION"' Params: 

13 and 14 are in the wrong order.

Comment by Guilherme Blanco [ 03/Aug/13 ]

This situation is not supported and cannot be resolved within current Doctrine code.
You created a circular dependency between the entities A and B. It happened because A contains one B (oneToOne) and because B contains a pointer to A as part of oneToMany association.
That way, you'll always have a foreign key constraint issue from RDBMS, no matter which entity you try to remove first.

Because of that, I'mm marking this ticket as "can't fix".

Comment by Matthieu Napoli [ 05/Aug/13 ]

Guilherme Blanco I see what you mean, but the case we submitted is with a nullable foreign key. So the operation is permitted by the RDBMS.

A has one B (nullable oneToOne), and B has a pointer to A (manyToOne, not nullable).

As I said for the query log, B should be removed first, which is not the case (see above, line 13 and 14 should be inversed).

So this is fixable on the Doctrine side if I'm not mistaken.

Comment by Benjamin Eberlei [ 03/Jan/14 ]

Matthieu Napoli is this fixed with your DDC-2775 PR?

Comment by Matthieu Napoli [ 15/Jan/14 ]

Just for clarity (I answered this question in the pull request): no this is not fixed (see https://github.com/doctrine/doctrine2/pull/707#issuecomment-31564035).

Comment by Benjamin Morel [ 04/Dec/14 ]

Just encountered what I believe to be the same bug, without any kind of circular dependency:

class A {
    /**
     * @ORM\OneToMany(targetEntity="B", mappedBy="a", indexBy="x", cascade={"all"}, orphanRemoval=true)
     */
    private $b;

    ...
}

class B {
    /*
     * @ORM\ManyToOne(targetEntity="A", inversedBy="b")
     * @ORM\JoinColumn(name="aid", referencedColumnName="id", nullable=false, onDelete="CASCADE")
     */
    private $a;

    ...
}

The following operations in A:

$this->b->clear();
$this->b->add(new B());

Result in the following SQL commands:

INSERT INTO B ...
DELETE FROM B ...

This is always the wrong commit order, and is doomed to fail when you have unique constraints in the B table.

Comment by Maxim Kapkaev [ 19/Dec/14 ]

Another situation without circular dependency:

class Entity
{
    /**
     * @ORM\OneToMany(targetEntity="Picture", mappedBy="entity", fetch="EXTRA_LAZY", cascade={"all"}, orphanRemoval=true)
     * @ORM\OrderBy({"position" = "ASC"})
     */
    protected $pictures = array();
} 

class Pictures {
    /**
     * @ORM\Column(type="string", length=1024, unique = true)
     */
    protected $file;
}
$hotel->setPictures($picturesArray);
$em->flush();
$hotel->getPictures()->clear();
$hotel->setPictures($somePictureUpdatedArray);
$em->flush();
Unique violation: 7 ERROR:  duplicate key value violates unique constraint "uniq_8f7c2fc08c9f3610"

Why we can't invoke entity deletions method (executeDeletions, UnitOfWork#commit) before executeInserts?
https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/UnitOfWork.php#L385-L388
There is another way?

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-707] was labeled:
https://github.com/doctrine/doctrine2/pull/707





[DDC-2525] [GH-707] [#DDC-2524] Wrong commit order with cascade remove and double association Created: 24/Jun/13  Updated: 24/Jan/15  Resolved: 08/Sep/13

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of mnapoli:

Url: https://github.com/doctrine/doctrine2/pull/707

Message:

This PR contains the failing test cas for DDC-2524(http://www.doctrine-project.org/jira/browse/DDC-2524).



 Comments   
Comment by Doctrine Bot [ 31/Jul/13 ]

A related Github Pull-Request [GH-707] was closed:
https://github.com/doctrine/doctrine2/pull/707

Comment by Fabio B. Silva [ 08/Aug/13 ]

Closed, For more details see https://github.com/doctrine/doctrine2/pull/707

Comment by Benjamin Eberlei [ 08/Sep/13 ]

Was not merged

Comment by Doctrine Bot [ 04/Nov/13 ]

A related Github Pull-Request [GH-707] was reopened:
https://github.com/doctrine/doctrine2/pull/707

Comment by Doctrine Bot [ 27/Oct/14 ]

A related Github Pull-Request [GH-707] was closed:
https://github.com/doctrine/dbal/pull/707

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-707] was labeled:
https://github.com/doctrine/doctrine2/pull/707





[DDC-2363] Duplicated record with orphanRemoval and proxy Created: 22/Mar/13  Updated: 24/Jan/15

Status: Awaiting Feedback
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.3.2
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Manuele Menozzi Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: orphanRemoval, proxy
Environment:

Tested both Mac OS X and Ubuntu


Issue Links:
Duplicate
is duplicated by DDC-2364 [GH-625] [DDC-2363] Duplicated record... Open

 Description   

There is a problem that causes duplicate records are created when EntityManager has to remove an entity due to orphanRemoval. The problem occurs only with a double flush and referred object is a proxy.

I'm trying to submit a pull request for this ticket. Please, stand by.



 Comments   
Comment by Marco Pivetta [ 27/Mar/14 ]

Hey Manuele Menozzi, do you remember if this has been fixed? Are you still able to reproduce the problem?

Comment by Manuele Menozzi [ 27/Mar/14 ]

Hi Marco,
I made a PR (https://github.com/doctrine/doctrine2/pull/625) with an automated test that reproduce the problem. I just ran this test over latest version of doctrine2 and it's still failed. So, the problem has not be fixed and I (or you) can reproduce it easily.

Let me know if I can help you somehow.

Comment by Marco Pivetta [ 27/Mar/14 ]

Thanks, didn't see it!

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-625] was labeled:
https://github.com/doctrine/doctrine2/pull/625





[DDC-2364] [GH-625] [DDC-2363] Duplicated record with orphanRemoval and proxy Created: 22/Mar/13  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Duplicate
duplicates DDC-2363 Duplicated record with orphanRemoval ... Awaiting Feedback

 Description   

This issue is created automatically through a Github pull request on behalf of mmenozzi:

Url: https://github.com/doctrine/doctrine2/pull/625

Message:

See http://www.doctrine-project.org/jira/browse/DDC-2363.



 Comments   
Comment by Doctrine Bot [ 30/Jun/14 ]

A related Github Pull-Request [GH-625] was closed:
https://github.com/doctrine/dbal/pull/625

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-625] was labeled:
https://github.com/doctrine/doctrine2/pull/625





[DDC-3341] SessionValidator gives an error message on orderBy association, but it is no error. Created: 07/Oct/14  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: Git Master
Fix Version/s: None
Security Level: All

Type: Bug Priority: Minor
Reporter: Tobias Feijten Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: orderBy, orm


 Description   

For @OrderBy annotations, the \Doctrine\ORM\Tools\SchemaValidator only checks if a field with the designated name exists at the designated Entity.
In the case of ordering on an association, defined in the target Entity, this is of course not the case, rendering an error like "The association Idb\TicketBundle\Entity\Ticket#ticketReservations is ordered by a foreign field ticketreservationtype_id that is not a field on the target entity Idb\TicketBundle\Entity\TicketReservation"
However, the \Doctrine\ORM\Persisters\BasicEntityPersister\getOrderBySQL function perfectly supports associations to order on.
Therefore, the error message should not be given when using an association existing at the designated Entity, as it's working and no mistake.
Could this be fixed?



 Comments   
Comment by Marco Pivetta [ 07/Oct/14 ]

Tobias Feijten provide a failing test case to demonstrate the problem first

Comment by Tobias Feijten [ 07/Oct/14 ]

Idb\TicketBundle\Entity\Ticket

namespace Idb\TicketBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

class Ticket {

  /**
   * @ORM\OneToMany(targetEntity="Idb\TicketBundle\Entity\TicketReservation", mappedBy="ticket", cascade={"persist","remove"})
   * @ORM\OrderBy({"ticketReservationType" = "ASC", "amount" = "DESC"})
   */
  private $ticketReservations;

}

Idb\TicketBundle\Entity\TicketReservation

namespace Idb\TicketBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

class TicketReservation {

  /**
   * @ORM\ManyToOne(targetEntity="Idb\TicketBundle\Entity\TicketReservationType")
   * @ORM\JoinColumn(name="ticketreservationtype_id", referencedColumnName="id")
   */
  private $ticketReservationType;

  /**
   * @var integer
   * @ORM\Column(name="amount", type="integer", nullable=false)
   */
  private $amount;

}

The orderBy on amount gives no error when validating the schema, the orderBy on ticketReservationType does (* The association Idb\TicketBundle\Entity\Ticket#ticketReservations is ordered by a foreign field ticketReservationType that is not a field on the target entity Idb\TicketBundle\Entity\TicketReservation).
However, the orderBy statement is not wrong as it is carried out perfectly when using the code.
The only problem is when validating.

Comment by Tobias Feijten [ 13/Oct/14 ]

Marco Pivetta Any progress on this one yet? Or do you need more information?

Comment by Marco Pivetta [ 13/Oct/14 ]

Any progress on this one yet?

No, no progress so far, and I can't allocate time for D2 over the next few weeks.
As for the information amount, it seems sufficient to me: we are probably just using field mappings without checking association mappings when looking for order fields. There is still a problem about what to do with composite identifiers or derived identifiers, but it should be covered by tests first.

Comment by Tobias Feijten [ 24/Jan/15 ]

Marco Pivetta I'm sorry for asking, but still no progress for this ticket? Any ETA? Half a year would be fine (for instance), just keep us up-to-date.

Comment by Marco Pivetta [ 24/Jan/15 ]

Tobias Feijten I honestly worked on a load of other tickets, but not on this one.

If you want an ETA, start looking into it yourself, as I can't pack it into the 2.5 release myself due to time constraints.





[DDC-3508] andWhere('... OR...') syntax ignores a newly added field Created: 16/Jan/15  Updated: 23/Jan/15  Resolved: 23/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: 2.3
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Julien Villetorte Assignee: Guilherme Blanco
Resolution: Invalid Votes: 0
Labels: dql, querybuilder
Environment:

CentOS



 Description   

Doctrine v2.3.6

All caches cleared before reporting.

After adding a new field on an already existing entity (field "question" on a "News" entity), this field is ignored when using the addWhere('.... OR ...') syntax, while it's working using a $qb->expr()->orX() syntax:

Not working (missing "question" column in SELECT of the generated SQL, and objects hydrated with a question's value of null) :

$qb = $this->createQueryBuilder('n');

$qb
    ->where('n.state = :state')
    ->andWhere('n.startAt <= :now')
    ->andWhere('n.endAt >= :now OR n.endAt is NULL') // Ignores the question field, don't know why
    ->setParameter('state', News::ACTIVE)
    ->setParameter('now', new \DateTime())
    ->orderBy('n.createdAt', 'DESC');

This syntax works:

$qb = $this->createQueryBuilder('n');

$qb
    ->where('n.state = :state')
    ->andWhere('n.startAt <= :now')
    ->andWhere($qb->expr()->orX(
        $qb->expr()->gte('n.endAt', ':now'),
        $qb->expr()->isNull('n.endAt')
    ))
    ->setParameter('state', News::ACTIVE)
    ->setParameter('now', new \DateTime())
    ->orderBy('n.createdAt', 'DESC');

Notes:

  • If I add an extra ->addSelect('n.question'), the field shows up twice in the generated SQL.
  • If I remove the orderBy statement or the "OR n.endAt is NULL" part, the field shows up in the SQL.
  • The generated DQL of both queries is exactly the same:
    SELECT n FROM [...]\Entity\News n WHERE n.state = :state AND n.startAt <= :now AND (n.endAt >= :now OR n.endAt IS NULL) ORDER BY n.createdAt DESC
    


 Comments   
Comment by Marco Pivetta [ 23/Jan/15 ]

Julien Villetorte why was this marked as invalid? Was it already fixed in 2.4?





[DDC-3533] [GH-1279] [Doc][Reference][2nd level cache] Created: 23/Jan/15  Updated: 23/Jan/15  Resolved: 23/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Documentation, Second Level Cache
Affects Version/s: Git Master
Fix Version/s: 2.5
Security Level: All

Type: Documentation Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: documentation, rst, second-level-cache, typo


 Description   

This issue is created automatically through a Github pull request on behalf of phansys:

Url: https://github.com/doctrine/doctrine2/pull/1279

Message:

  • Fixed typo in TimestampRegion title.
  • Normalized php snippets (comments, indentation).


 Comments   
Comment by Doctrine Bot [ 23/Jan/15 ]

A related Github Pull-Request [GH-1279] was assigned:
https://github.com/doctrine/doctrine2/pull/1279

Comment by Doctrine Bot [ 23/Jan/15 ]

A related Github Pull-Request [GH-1279] was merged:
https://github.com/doctrine/doctrine2/pull/1279





[DDC-3527] Provide a method to retrieve exactly one entity out of entity repository Created: 20/Jan/15  Updated: 22/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: Git Master
Fix Version/s: 3.0

Type: Improvement Priority: Minor
Reporter: Dominik D Assignee: Marco Pivetta
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Hello,

currently we have EntityRepository::findOneBy() method for retrieving a single or none entities out of an EntityRepository. It would be very useful, if there was a method which retrieves exactly one entity or throws NonUniqueResultException in case of multiple records returned or NoResultException in case of zero results returned (just like Query::getSingleResult() currently does).

Very often I find myself creating custom repositories for a couple of ::findOneByOrThrow() methods only. Needless to say it's quite mundane to do. The bodies of such methods follows the same pattern:

1. Query the EntityRepository using EntityRepository::findOneBy().
2. If the result is null, then throw an Exception.
3. Return the result.

It'd be very nice to have it out-of-the-box in the base EntityRepository.

Thanks.



 Comments   
Comment by Marco Pivetta [ 20/Jan/15 ]

We actually want to reduce the repository API, not expand it...

Comment by Dominik D [ 21/Jan/15 ]

Wow, ok. I guess you've got good reasons for it and I shouldn't try to convince you, that having methods for most common use cases out of the box is quite convenient?

If yes, then fine. I can create a common EntityRepository subclass for myself and put any helper methods I want there. This would at least cut down on the code duplication in my codebase.

If what you say is final, then we can close this ticket.

Cheers.

Comment by Marco Pivetta [ 22/Jan/15 ]

I guess you've got good reasons for it and I shouldn't try to convince you, that having methods for most common use cases out of the box is quite convenient?

The main problem is that adding API methods to repositories forces any subclasses to also apply eventual filtering logic to those as well.

Other than that, it's merely a question of interface segregation: the current API is hardly maintainable if we assume that many developers subclassed the EntityRepository class, therefore we should keep it locked until 3.x.

I'll actually mark this issue for 3.0 and defer discussion till then.

Comment by Dominik D [ 22/Jan/15 ]

Ok, thanks.





[DDC-3530] [GH-1276] travis: run coverage just once Created: 22/Jan/15  Updated: 22/Jan/15  Resolved: 22/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Tools
Affects Version/s: 2.4.7
Fix Version/s: 2.4.8
Security Level: All

Type: Improvement Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: build-speed, ci, coverage, travis


 Description   

This issue is created automatically through a Github pull request on behalf of TomasVotruba:

Url: https://github.com/doctrine/doctrine2/pull/1276

Message:

Another speedup, just for 2.4 branch. Ref: https://github.com/doctrine/doctrine2/pull/1251

2.3 and bellow don't use coverage, so that should be all.



 Comments   
Comment by Doctrine Bot [ 22/Jan/15 ]

A related Github Pull-Request [GH-1276] was assigned:
https://github.com/doctrine/doctrine2/pull/1276

Comment by Doctrine Bot [ 22/Jan/15 ]

A related Github Pull-Request [GH-1276] was merged:
https://github.com/doctrine/doctrine2/pull/1276





[DDC-3518] [GH-1266] [2.4] Fix schema generation in the test suite Created: 18/Jan/15  Updated: 22/Jan/15  Resolved: 22/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Tools
Affects Version/s: 2.4.7
Fix Version/s: 2.4.8
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: ci, testsuite, travis


 Description   

This issue is created automatically through a Github pull request on behalf of Ocramius:

Url: https://github.com/doctrine/doctrine2/pull/1266

Message:

This PR backports doctrine/doctrine2@b314476599954086f1eaa43800901b9d817df257 into 2.4



 Comments   
Comment by Doctrine Bot [ 18/Jan/15 ]

A related Github Pull-Request [GH-1266] was assigned:
https://github.com/doctrine/doctrine2/pull/1266

Comment by Doctrine Bot [ 22/Jan/15 ]

A related Github Pull-Request [GH-1266] was merged:
https://github.com/doctrine/doctrine2/pull/1266





[DDC-3378] [GH-1176] Support merging entities with composite identities defined through to-one associations Created: 07/Nov/14  Updated: 22/Jan/15  Resolved: 22/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: Git Master, 2.4.7
Fix Version/s: 2.5
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: association, composite-identifier, identifier, many-to-one, merge, one-to-one


 Description   

This issue is created automatically through a Github pull request on behalf of adrienbrault:

Url: https://github.com/doctrine/doctrine2/pull/1176

Message:

I hope that I'm doing something wrong and that this is not a bug ...



 Comments   
Comment by Doctrine Bot [ 22/Jan/15 ]

A related Github Pull-Request [GH-1176] was assigned:
https://github.com/doctrine/doctrine2/pull/1176

Comment by Doctrine Bot [ 22/Jan/15 ]

A related Github Pull-Request [GH-1176] was closed:
https://github.com/doctrine/doctrine2/pull/1176





[DDC-2170] Decorator base classes for query related objects Created: 26/Nov/12  Updated: 22/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: New Feature Priority: Major
Reporter: Lars Strojny Assignee: Marco Pivetta
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Doctrine\ORM\Query should not be directly extendable but it would be nice to decorate query objects and add additional methods. Use cases are e.g. doctrine-fun (see https://github.com/lstrojny/doctrine-fun/blob/master/src/Doctrine/Fun/Query.php) or even cases where users want to add domain specific methods. As Doctrine\ORM\Query is final it is not so easy to decorate correctly. I would propose:

  • Add a new interfaces: Doctrine\ORM\QueryInterface that provides a contract for all methods Doctrine\ORM\Query provides
  • Add a decorator base class Doctrine\ORM\QueryDecorator as an extension point
  • Some for NativeQuery and QueryBuilder


 Comments   
Comment by Lars Strojny [ 26/Nov/12 ]

Related:

Comment by Aurimas Niekis [ 21/Jan/15 ]

Any changes on this?

Comment by Marco Pivetta [ 22/Jan/15 ]

The EntityManagerInterface now allows producing custom query objects: just requires a custom createQuery or createQueryBuilder API.

Comment by Aurimas Niekis [ 22/Jan/15 ]

Yes, but you can't extend `Doctrine\ORM\Query` object, and many places expects `Doctrine\ORM\Query` not your custom query object

Comment by Marco Pivetta [ 22/Jan/15 ]

Oh, I see what you mean.

Yes, those still require patching, so I suggest getting your hands dirty and trying with a pull request





[DDC-3503] [GH-1257] Resolve target entity also in discriminator map (allows interfaces and custom names in discriminator map) Created: 15/Jan/15  Updated: 22/Jan/15  Resolved: 22/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Mapping Drivers
Affects Version/s: Git Master
Fix Version/s: 2.5
Security Level: All

Type: New Feature Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: discriminator-map, inheritance, metadata, resolve-target-entities

Issue Links:
Dependency
is required for DDC-3300 [GH-1130] [WIP] Added resolve entitie... Resolved
Reference
is referenced by DDC-3512 Redesign ClassMetadata API as ValueOb... Open

 Description   

This issue is created automatically through a Github pull request on behalf of Ocramius:

Url: https://github.com/doctrine/doctrine2/pull/1257

Message:

This PR supersedes #1130 (DDC-3300(http://www.doctrine-project.org/jira/browse/DDC-3300)).

The final aim of the PR is to be able to define following in discriminator maps:

```php
/** @DiscriminatorMap(

{"foo" = "FooInterface", "bar" = "BarConcreteImpl"}

) */
```



 Comments   
Comment by Doctrine Bot [ 15/Jan/15 ]

A related Github Pull-Request [GH-1130] was assigned:
https://github.com/doctrine/doctrine2/pull/1130

Comment by Doctrine Bot [ 16/Jan/15 ]

A related Github Pull-Request [GH-1257] was assigned:
https://github.com/doctrine/doctrine2/pull/1257

Comment by Doctrine Bot [ 16/Jan/15 ]

A related Github Pull-Request [GH-1130] was closed:
https://github.com/doctrine/doctrine2/pull/1130

Comment by Doctrine Bot [ 22/Jan/15 ]

A related Github Pull-Request [GH-1257] was closed:
https://github.com/doctrine/doctrine2/pull/1257





[DDC-3300] [GH-1130] [WIP] Added resolve entities support in discrim. map Created: 09/Sep/14  Updated: 22/Jan/15  Resolved: 22/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Mapping Drivers
Affects Version/s: Git Master
Fix Version/s: 2.5
Security Level: All

Type: New Feature Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: discriminator-map, inheritance, metadata, resolve-target-entities

Issue Links:
Dependency
depends on DDC-3503 [GH-1257] Resolve target entity also ... Resolved
Reference
relates to DDC-3385 [GH-1181] Support fetching entities b... Resolved

 Description   

This issue is created automatically through a Github pull request on behalf of mmoreram:

Url: https://github.com/doctrine/doctrine2/pull/1130

Message:

This PR is WIP. I just wanted to know if what I am doing is wrong or I can go on with tests and documentation.

This is what happens.

I have nicely the ability to define a relation using just the interfaces, and then, resolve these relations overriding the interfaces with the implementations. This resolves a big problem: Multiple implementations of one interface.

But, when you define a discriminatorMap, you *Must* define it using specific implementations, so all this flexibility gained in the relations is lost at this point.

Using a new listener, its easy to override this interfaces.

What do you think?



 Comments   
Comment by Doctrine Bot [ 15/Jan/15 ]

A related Github Pull-Request [GH-1130] was assigned:
https://github.com/doctrine/doctrine2/pull/1130

Comment by Doctrine Bot [ 16/Jan/15 ]

A related Github Pull-Request [GH-1130] was closed:
https://github.com/doctrine/doctrine2/pull/1130

Comment by Marco Pivetta [ 22/Jan/15 ]

Handled in DDC-3503





[DDC-3465] [GH-1232] Explicit example of partial indexes Created: 29/Dec/14  Updated: 22/Jan/15  Resolved: 22/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Mapping Drivers
Affects Version/s: None
Fix Version/s: 2.5
Security Level: All

Type: Documentation Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: column-options, ddl, index, partial-index


 Description   

This issue is created automatically through a Github pull request on behalf of PowerKiKi:

Url: https://github.com/doctrine/doctrine2/pull/1232

Message:

This provide an explicit example of partial indexes annotations. Specifically including all parentheses as returned by PostgreSql.

This is needed following https://github.com/doctrine/dbal/pull/716



 Comments   
Comment by Doctrine Bot [ 29/Dec/14 ]

A related Github Pull-Request [GH-1232] was assigned:
https://github.com/doctrine/doctrine2/pull/1232

Comment by Doctrine Bot [ 22/Jan/15 ]

A related Github Pull-Request [GH-1232] was merged:
https://github.com/doctrine/doctrine2/pull/1232





[DDC-3525] Exception "The column id must be mapped to a field in class" when associationKey used Created: 20/Jan/15  Updated: 21/Jan/15

Status: Awaiting Feedback
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.4.7
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Ilya Antipenko Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: associationKey, foreign-key

Attachments: Text File foreign-key.log    

 Description   

I have issue when I use "associationKey"

I create test repo for reproduce this issue:
https://github.com/aivus/symfony2-foreign-bug

1. composer install
2. Set DB parameters in app/config/parameters.yml and create DB
3. php app/console doctrine:schema:create --force
4. php app/console server:run
5. Load fixtures: http://127.0.0.1:8000/app/loadFixture
6. Try to get list: http://127.0.0.1:8000/app_dev.php/admin/app/app/order/list

I make workaround, which works for me (https://github.com/aivus/doctrine2/commit/8461111e8aea98d02175f3642870a689d446beef), but I'm not sure about it



 Comments   
Comment by Ilya Antipenko [ 21/Jan/15 ]

Add stacktrace





[DDC-3526] [GH-1273] Incorrect @throws doc. in getSingleScalarResult Created: 20/Jan/15  Updated: 20/Jan/15  Resolved: 20/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: 2.4.7
Fix Version/s: 2.5
Security Level: All

Type: Documentation Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: docblock, query


 Description   

This issue is created automatically through a Github pull request on behalf of TrkiSF2:

Url: https://github.com/doctrine/doctrine2/pull/1273

Message:

This method doesn't throw QueryException.

The documentation should says that it throws: "NoResultException" or "NonUniqueResultException"



 Comments   
Comment by Doctrine Bot [ 20/Jan/15 ]

A related Github Pull-Request [GH-1273] was assigned:
https://github.com/doctrine/doctrine2/pull/1273

Comment by Doctrine Bot [ 20/Jan/15 ]

A related Github Pull-Request [GH-1273] was merged:
https://github.com/doctrine/doctrine2/pull/1273





[DDC-3215] wrong quotation Created: 16/Jul/14  Updated: 20/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: DQL, ORM
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: revrev Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 1
Labels: dql, orm


 Description   

when doctrine build query´s, for example when you doing

$entitity->getTest()->clear();

following queries are generated (test_id is integer in mysql):

DELETE FROM test WHERE test_id = '6'

Is this right?
For me the right query would be:

DELETE FROM test WHERE test_id = 6

as in http://dev.mysql.com/doc/refman/5.5/en/type-conversion.html
6 will be converted to float, this can be an issue, or?

Comparisons that use floating-point numbers (or values that are converted to floating-point numbers) are approximate because such numbers are inexact. This might lead to results that appear inconsistent:

mysql> SELECT '18015376320243458' = 18015376320243458;
        -> 1
mysql> SELECT '18015376320243459' = 18015376320243459;
        -> 0

this also happens in dql sometimes, why doctrine does this not automatic right due to description in the entities?

     /**
     * @ORM\Id @ORM\Column(type="integer")
     * @ORM\GeneratedValue
     */


 Comments   
Comment by Marco Pivetta [ 16/Jul/14 ]

Could you please convert this to a failing test case? Doctrine doesn't quote integers as strings by default.

Comment by revrev [ 16/Jul/14 ]

i try to describe what i have done

i have an Entity with:

    /**
     * @ORM\ManyToMany(targetEntity="Messen", inversedBy="vertrag_messen")
     * @ORM\JoinTable(name="vertrag_messen")
     **/
    private $vertrag_messen;

    public function __construct()
    {
        $this->vertrag_messen = new \Doctrine\Common\Collections\ArrayCollection();
    }

    public function getMessen()
    {
        return $this->vertrag_messen;
    }

when i now clear the Data

$entitity->getMessen()->clear();

following query is created
DELETE FROM vertrag_messen where messe_id = '6'

Should here not set the value 6 as integer (param_int) (DELETE FROM test vertrag_messen where messe_id = 6) that mysql doesn´t have to cast the value? (http://dev.mysql.com/doc/refman/5.5/en/type-conversion.html) or is this not an problem?

Comment by Marco Pivetta [ 16/Jul/14 ]

is messe_id in your entity an integer or a string at the moment in time when that query is being executed?

Comment by revrev [ 16/Jul/14 ]

the value comes automatic
$entitity = $em->getRepository('Base\Entities\Vertrag')>find(intval($data["id"]));

i don´t set messe_id here

Comment by Marco Pivetta [ 16/Jul/14 ]

Can you var_dump the Base\Entities\Messe instance?

Comment by revrev [ 16/Jul/14 ]

object(stdClass)#1014 (64) {
["__CLASS__"]=>
string(24) "Base\Entities\Vertrag"
["id"]=>
int(6)
[„vertrag_messen"]=>
array(1)

Unknown macro: { [0]=> string(20) "BaseEntitiesMessen" }


["erstellungsdatum"]=>
object(stdClass)#1210 (3)

Unknown macro: { ["__CLASS__"]=> string(8) "DateTime" ["date"]=> string(25) "2013-09-28T00}

["zeitraumvon"]=>
NULL
["zeitraumbis"]=>
NULL
["jahr"]=>
int(2014)
["created"]=>
object(stdClass)#1178 (3)

Unknown macro: { ["__CLASS__"]=> string(8) "DateTime" ["date"]=> string(25) "2013-09-28T19}

["updated"]=>
object(stdClass)#1177 (3)

Unknown macro: { ["__CLASS__"]=> string(8) "DateTime" ["date"]=> string(25) "2014-07-16T17}

["uuid"]=>
string(36) "52470c58-4288-45eb-b75f-0c41c0a81437"
}

Comment by Marco Pivetta [ 17/Jul/14 ]

yeah, integer identifier there.
Could you verify if the problem also comes up with current master? I think this issue is related with another one that was fixed some months ago in 2.5.x-dev

Comment by Mathias Dietrich [ 20/Jan/15 ]

@Marco Pivetta:

I was affected by exact the same issue. Even when running git master at the beginning of last week, it was still broken.
Today I retestet. Luckily your latest commits (from beginning with: 445798ed46291f2639b3657142bd2f934d1be8a6) to the BasicEntityPersister seemed fixed it.

@revrev:
Could you please retest your example? This bug might be fixed. Thx.





[DDC-3521] [GH-1269] [DDC-3520] self-update composer before install Created: 20/Jan/15  Updated: 20/Jan/15  Resolved: 20/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Tools
Affects Version/s: Git Master
Fix Version/s: 2.5
Security Level: All

Type: Improvement Priority: Major
Reporter: Doctrine Bot Assignee: Guilherme Blanco
Resolution: Fixed Votes: 0
Labels: composer, travis

Issue Links:
Duplicate
is duplicated by DDC-3522 [GH-1270] Update composer on travis b... Resolved

 Description   

This issue is created automatically through a Github pull request on behalf of spdionis:

Url: https://github.com/doctrine/doctrine2/pull/1269

Message:

Updating composer before install seems like a good idea. At the moment for example the travis build is failing because of the new composer syntax with '^' and it would be fixed by composer self-update.

Sorry for the spam, opened the pull request against master this time.



 Comments   
Comment by Doctrine Bot [ 20/Jan/15 ]

A related Github Pull-Request [GH-1269] was merged:
https://github.com/doctrine/doctrine2/pull/1269





[DDC-3522] [GH-1270] Update composer on travis build. Created: 20/Jan/15  Updated: 20/Jan/15  Resolved: 20/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Improvement Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Duplicate Votes: 0
Labels: None

Issue Links:
Duplicate
duplicates DDC-3521 [GH-1269] [DDC-3520] self-update comp... Resolved

 Description   

This issue is created automatically through a Github pull request on behalf of guilhermeblanco:

Url: https://github.com/doctrine/doctrine2/pull/1270

Message:



 Comments   
Comment by Doctrine Bot [ 20/Jan/15 ]

A related Github Pull-Request [GH-1270] was closed:
https://github.com/doctrine/doctrine2/pull/1270





[DDC-3516] [GH-1264] Add Changelog/Migration to 2.5 documentation chapter. Created: 18/Jan/15  Updated: 20/Jan/15  Resolved: 20/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: 2.5
Security Level: All

Type: Documentation Priority: Critical
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: documentation, upgrade-notes


 Description   

This issue is created automatically through a Github pull request on behalf of beberlei:

Url: https://github.com/doctrine/doctrine2/pull/1264

Message:

new chapter in documentation for migrating to 2.5. Includes a changelog of new features and improvements as well as BC breaks from UPGRADE.md



 Comments   
Comment by Doctrine Bot [ 20/Jan/15 ]

A related Github Pull-Request [GH-1264] was merged:
https://github.com/doctrine/doctrine2/pull/1264

Comment by Doctrine Bot [ 20/Jan/15 ]

A related Github Pull-Request [GH-1264] was assigned:
https://github.com/doctrine/doctrine2/pull/1264





[DDC-3523] [GH-1271] Update migration_2_5.rst Created: 20/Jan/15  Updated: 20/Jan/15  Resolved: 20/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Documentation
Affects Version/s: 2.5
Fix Version/s: 2.5
Security Level: All

Type: Documentation Priority: Minor
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: upgrade-notes


 Description   

This issue is created automatically through a Github pull request on behalf of kix:

Url: https://github.com/doctrine/doctrine2/pull/1271

Message:

Fixed some formatting issues and typos.






[DDC-3520] [GH-1268] Update composer before install Created: 20/Jan/15  Updated: 20/Jan/15  Resolved: 20/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: 2.4
Fix Version/s: None
Security Level: All

Type: Improvement Priority: Minor
Reporter: Doctrine Bot Assignee: Steve Müller
Resolution: Incomplete Votes: 0
Labels: composer, self-update, tests, travis


 Description   

This issue is created automatically through a Github pull request on behalf of spdionis:

Url: https://github.com/doctrine/doctrine2/pull/1268

Message:

Updating composer before install seems like a good idea. At the moment for example the travis build is failing because of the new composer syntax with '^' and it would be fixed by composer self-update.



 Comments   
Comment by Doctrine Bot [ 20/Jan/15 ]

A related Github Pull-Request [GH-1268] was closed:
https://github.com/doctrine/doctrine2/pull/1268





[DDC-2991] [GH-957] makes doctrine less dependent upon the symfony yaml component Created: 20/Feb/14  Updated: 18/Jan/15  Resolved: 23/Mar/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: 2.5
Security Level: All

Type: Improvement Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of thealjey:

Url: https://github.com/doctrine/doctrine2/pull/957

Message:

This is the last place in the framework where the class is just too tightly coupled with the symfony yaml component, that the yaml parser alone cannot be overridden without overriding an entire class.
I simply brought it in accordance with "Doctrine\ORM\Mapping\Driver\YamlDriver" where a separate method called loadMappingFile exists to parse the mapping file.



 Comments   
Comment by Doctrine Bot [ 23/Mar/14 ]

A related Github Pull-Request [GH-957] was closed:
https://github.com/doctrine/doctrine2/pull/957





[DDC-2865] [GH-882] Efficient counting on Criteria Created: 19/Dec/13  Updated: 18/Jan/15  Resolved: 16/May/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: None
Fix Version/s: 2.5
Security Level: All

Type: Improvement Priority: Major
Reporter: Doctrine Bot Assignee: Guilherme Blanco
Resolution: Fixed Votes: 0
Labels: collection, lazy-criteria-collection, lazy-loading

Issue Links:
Reference
is referenced by DDC-2217 Return a lazy collection from Persist... Resolved

 Description   

This issue is created automatically through a Github pull request on behalf of bakura10:

Url: https://github.com/doctrine/doctrine2/pull/882

Message:

Hi,

This is an attempt to solve this very annoying issue: http://www.doctrine-project.org/jira/browse/DDC-2217

I'm not sure about my solution as I'm not really into Doctrine internals.

  1. Use case

I have a library that is based exclusively on Criteria API. A Paginator adapter uses an empty Criteria to count how many elements are in the collection. However, EntityRepository's matching method always initialize the whole collection into an ArrayCollection. This is unusable in most cases and make the API unusable for my use case.

  1. Solution

I've created a new LazyCollectionCriteria that implements an efficient count. I think the cleanest solution would be to add a method to the Selectable interface: with a count method. But I think this is not possible now, unfortunately.

If the solution seems nice to you, I'll write the tests.

ping @ocramius, @mac_nibblet and @thinkscape (this should make ZfrRest usable )



 Comments   
Comment by Doctrine Bot [ 16/May/14 ]

A related Github Pull-Request [GH-882] was closed:
https://github.com/doctrine/doctrine2/pull/882





[DDC-2217] Return a lazy collection from PersistentCollection::match($criteria) Created: 31/Dec/12  Updated: 18/Jan/15  Resolved: 16/May/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: None
Fix Version/s: 2.5
Security Level: All

Type: Improvement Priority: Major
Reporter: Christophe Coevoet Assignee: Guilherme Blanco
Resolution: Fixed Votes: 8
Labels: collection, lazy-criteria-collection, lazy-loading

Issue Links:
Reference
relates to DDC-2865 [GH-882] Efficient counting on Criteria Resolved

 Description   

In 2.3, PersistentCollection::match() has been implemented by doing the query directly. But sometimes, the only meaningful information about the matched collection would be its length. In this case, it would be great to handle it in the same way than extra lazy collections are handled: the matched collection would be initialized lazily, and could do the count in an extra lazy way (if the original collection was extra lazy).
This would of course not change anything in the case where the original collection was already initialized.



 Comments   
Comment by Maciej Klemarczyk [ 20/Sep/13 ]

It will be very usefull, for example to compute count of rows.

In 300 rows, you do not want fetch data from database to compute length of this.

Function matching(Criteria $criteria) fetch too many data for just compute count of rows.

Comment by Christophe Coevoet [ 21/Sep/13 ]

This is exactly the use case I add in mind actually

Comment by Michaël Gallego [ 12/Oct/13 ]

+1 on this one! This is absolutely needed when we use the Selectable API as the abstraction for some libraries.





[DDC-3512] Redesign ClassMetadata API as ValueObject based (for type-safety and self-documentation) Created: 17/Jan/15  Updated: 18/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: Mapping Drivers, ORM
Affects Version/s: None
Fix Version/s: 3.0
Security Level: All

Type: Improvement Priority: Critical
Reporter: Marco Pivetta Assignee: Marco Pivetta
Resolution: Unresolved Votes: 0
Labels: classmetadatafactory, cleanup, metadata, performance, type-safety

Issue Links:
Reference
relates to DDC-3503 [GH-1257] Resolve target entity also ... Resolved

 Description   

The current ClassMetadata API is based on a lot of array juggling (for performance reasons).

While that was understandable with PHP 5.3, all the array access operations are currently:

  • slowing things down
  • making the code very hard to read/understand

I suggest re-coding the ClassMetadata internals (public properties and such) so that well-described properties are defined.

Additionally, as a bonus, we'd get a performance boost by just moving all the class-alias and type resolution logic from the runtime into the ClassMetadataFactory (or similar) API, saving tons of performance at every run.

In pseudo-logic, what I'd like to achieve with DDC-3512 is:

  • base metadata is loaded from the mapping driver
  • onLoadMetadata event is fired for each loaded metadata instance
  • metadata is completed by the ClassMetadataFactory logic
  • onCompleteMetadata event is fired for each loaded metadata instance

This would make metadata manipulation from events a bit messier (user needs to know which value to change during which event), but would allow using better constrained metadata structures in future, and that would disallow mistakes during event listeners execution as well (internal validation).






[DDC-3453] [GH-1223] Refactored construction of the EntityManager out to an EntityManagerFactory Created: 17/Dec/14  Updated: 18/Jan/15  Resolved: 18/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Improvement Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Won't Fix Votes: 0
Labels: constructor, entitymanager, setup

Issue Links:
Reference
relates to DDC-3515 [GH-1263] #1223 DDC-3453 - make `Enti... Open

 Description   

This issue is created automatically through a Github pull request on behalf of guiwoda:

Url: https://github.com/doctrine/doctrine2/pull/1223

Message:

Added tests for the factory (needed to refactor the OrmTestCase so I could reuse mock config and mock connections).

This pattern is well established in Hibernate, I've been wondering why we don't have it in Doctrine.



 Comments   
Comment by Doctrine Bot [ 18/Jan/15 ]

A related Github Pull-Request [GH-1223] was closed:
https://github.com/doctrine/doctrine2/pull/1223

Comment by Doctrine Bot [ 18/Jan/15 ]

A related Github Pull-Request [GH-1223] was assigned:
https://github.com/doctrine/doctrine2/pull/1223





[DDC-3490] [GH-1248] improved error handling for invalid association values #2 Created: 13/Jan/15  Updated: 18/Jan/15  Resolved: 18/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Mapping Drivers, ORM
Affects Version/s: None
Fix Version/s: 2.5
Security Level: All

Type: Improvement Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: association, changeset, exception-message, exceptions, invalid-state, mapping

Issue Links:
Reference
relates to DDC-3098 [GH-1016] improved error handling for... Resolved

 Description   

This issue is created automatically through a Github pull request on behalf of flip111:

Url: https://github.com/doctrine/doctrine2/pull/1248

Message:

Possibly to do:
1. Make custom Exception for line 713
2. Make custom Exception for line 817
3. Does the object check on line 816 slow down the code too much? Alternatively a try-catch could be put around line 1415 or higher up.

Previous: https://github.com/doctrine/doctrine2/pull/1016



 Comments   
Comment by Doctrine Bot [ 17/Jan/15 ]

A related Github Pull-Request [GH-1248] was assigned:
https://github.com/doctrine/doctrine2/pull/1248

Comment by Doctrine Bot [ 18/Jan/15 ]

A related Github Pull-Request [GH-1248] was closed:
https://github.com/doctrine/doctrine2/pull/1248





[DDC-3496] [GH-1252] Include className in calls to NamingStrategy joinColumnName method Created: 14/Jan/15  Updated: 17/Jan/15  Resolved: 17/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Mapping Drivers, ORM
Affects Version/s: None
Fix Version/s: 2.5
Security Level: All

Type: Improvement Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: naming-strategy


 Description   

This issue is created automatically through a Github pull request on behalf of jacksleight:

Url: https://github.com/doctrine/doctrine2/pull/1252

Message:

For consistency with `propertyToColumnName`, include the class name when generating names for join columns as well, for instances where you want to name columns (inc. join columns) based on the class that defined them.



 Comments   
Comment by Doctrine Bot [ 17/Jan/15 ]

A related Github Pull-Request [GH-1252] was closed:
https://github.com/doctrine/doctrine2/pull/1252

Comment by Doctrine Bot [ 17/Jan/15 ]

A related Github Pull-Request [GH-1252] was assigned:
https://github.com/doctrine/doctrine2/pull/1252





[DDC-2981] Multi get for second level cache (Doctrine Cache related) Created: 13/Feb/14  Updated: 17/Jan/15  Resolved: 17/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM, Second Level Cache
Affects Version/s: None
Fix Version/s: 2.5
Security Level: All

Type: Improvement Priority: Major
Reporter: Asmir Mustafic Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: cache, multi-get, performance, second-level-cache

Issue Links:
Reference
is referenced by DDC-2982 [GH-954] Multi Get support for Second... Resolved

 Description   

Hi every body!

I'm developing an application that is highly based on doctrine second-level cache feature.
Using memcache or redis as cache back-end, doctrine have to query thousand times for the cached values (especially on one-to-many and many-to-many associations).
This introduces a lot of latency (and network traffic)...

I'm thinking to add to Doctrine\Common\Cache\Cache interface a method fetchMulti(array $keys) that fetches multiple items in one call. In this way doctrine orm can ask for many items with just one call (for example, here https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php#L84 this feature can be very useful).

I have made some real-world tests and it can reduce highly the number of total queries (my app runs 190 cache requests instead of 900 cache requests)

Many vendors (memcache, redis, apc ecc) already offer this functionality, but with doctrine-cache we can't use it...

I'm going to implement this feature. Can it be accepted as a pull request?

It may be BC breaking:

  • it can be implemented adding a method inside Doctrine\Common\Cache\Cache interface (more BC breaking but more clean and elegant)
  • it can be implemented adding an interface Doctrine\Common\Cache\MultiCache and later CacheProvider can implement it (less BC breaking)


 Comments   
Comment by Marco Pivetta [ 13/Feb/14 ]

Adding a method to Doctrine\Common\Cache\Cache is not viable because of BC - a new interface would be ok

Comment by Asmir Mustafic [ 13/Feb/14 ]

ok, i agree with you.
But this forces me to check always here https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php#L95 if $this->cache is instance of MultiCache

Comment by Marco Pivetta [ 13/Feb/14 ]

Asmir Mustafic or you build a MultiCacheRegion

Comment by Asmir Mustafic [ 13/Feb/14 ]

It can be a good approach. I will try it.
I'm thinking to provide a default implementation of fetchMulti directly inside CacheProvider that internally loops over each key and call CacheProvider::fetch($id) to fetch its value.
Later i will overwrite this behavior inside vendor specific driver (ApcCache, RedisCache...)

Comment by Marco Pivetta [ 17/Jan/15 ]

Solved in DDC-2982





[DDC-2982] [GH-954] Multi Get support for Second Level Cache Created: 14/Feb/14  Updated: 17/Jan/15  Resolved: 17/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Second Level Cache
Affects Version/s: Git Master
Fix Version/s: 2.5
Security Level: All

Type: Improvement Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: cache, multi-get, performance, second-level-cache

Issue Links:
Reference
relates to DDC-2981 Multi get for second level cache (Doc... Resolved

 Description   

This issue is created automatically through a Github pull request on behalf of goetas:

Url: https://github.com/doctrine/doctrine2/pull/954

Message:

Hi!
As discussed [here](http://www.doctrine-project.org/jira/browse/DDC-2981) i have implemented some kind of multi-get for second level cache implementation.

I have also created a PR to doctrine/cache component (see https://github.com/doctrine/cache/pull/29) that enables this feature at driver cache level.



 Comments   
Comment by Doctrine Bot [ 15/Jan/15 ]

A related Github Pull-Request [GH-954] was assigned:
https://github.com/doctrine/doctrine2/pull/954

Comment by Doctrine Bot [ 17/Jan/15 ]

A related Github Pull-Request [GH-954] was closed:
https://github.com/doctrine/doctrine2/pull/954





[DDC-1590] Fix Inheritance in Code-Generation Created: 09/Jan/12  Updated: 17/Jan/15  Resolved: 18/Aug/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: 2.5
Security Level: All

Type: Improvement Priority: Major
Reporter: Benjamin Eberlei Assignee: Marco Pivetta
Resolution: Fixed Votes: 3
Labels: None

Issue Links:
Dependency
depends on DDC-3240 [GH-1098] #DDC-1590: Fix Inheritance ... Resolved
is required for DDC-1579 MappedSuperClass and inheritance prob... Resolved
Reference
is referenced by DDC-3464 [GH-1231] Backport 'Merge pull reques... Resolved

 Comments   
Comment by Lukas Domnick [ 10/Dec/12 ]

(I have no Link Privileges, but this one #DDC-1379 is a duplicate with more extent info.)





[DDC-3464] [GH-1231] Backport 'Merge pull request #1098 from encoder32/DDC-1590' to 2.4 branch Created: 26/Dec/14  Updated: 17/Jan/15  Resolved: 17/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Tools
Affects Version/s: 2.4.7
Fix Version/s: 2.4.8
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: entityGenerator, reflection, traits

Issue Links:
Reference
relates to DDC-1590 Fix Inheritance in Code-Generation Resolved

 Description   

This issue is created automatically through a Github pull request on behalf of aivus:

Url: https://github.com/doctrine/doctrine2/pull/1231

Message:

Backport #1098 to 2.4 branch



 Comments   
Comment by Doctrine Bot [ 28/Dec/14 ]

A related Github Pull-Request [GH-1231] was assigned:
https://github.com/doctrine/doctrine2/pull/1231

Comment by Doctrine Bot [ 17/Jan/15 ]

A related Github Pull-Request [GH-1231] was merged:
https://github.com/doctrine/doctrine2/pull/1231





[DDC-3240] [GH-1098] #DDC-1590: Fix Inheritance in Code-Generation Created: 03/Aug/14  Updated: 17/Jan/15  Resolved: 18/Aug/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: 2.5
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Dependency
is required for DDC-1590 Fix Inheritance in Code-Generation Resolved

 Description   

This issue is created automatically through a Github pull request on behalf of encoder32:

Url: https://github.com/doctrine/doctrine2/pull/1098

Message:

DDC-1590



 Comments   
Comment by Doctrine Bot [ 05/Aug/14 ]

A related Github Pull-Request [GH-1098] was assigned:
https://github.com/doctrine/doctrine2/pull/1098

Comment by Doctrine Bot [ 18/Aug/14 ]

A related Github Pull-Request [GH-1098] was closed:
https://github.com/doctrine/doctrine2/pull/1098

Comment by Doctrine Bot [ 28/Dec/14 ]

A related Github Pull-Request [GH-1231] was assigned:
https://github.com/doctrine/doctrine2/pull/1231

Comment by Doctrine Bot [ 17/Jan/15 ]

A related Github Pull-Request [GH-1231] was merged:
https://github.com/doctrine/doctrine2/pull/1231





[DDC-1379] Entity Generator Bug with extended classes Created: 16/Sep/11  Updated: 17/Jan/15  Resolved: 09/Jan/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: 2.3
Security Level: All

Type: Bug Priority: Major
Reporter: Mark Badolato Assignee: Benjamin Eberlei
Resolution: Duplicate Votes: 0
Labels: None


 Description   

I'm presently using Doctrine 2 in conjunction with Symfony 2 and have come across a bug with the Entity Generator when I'm extending an abstract class. Here's a minor example to demonstrate (please note, any annotations problems or typos are a result of my typing in this ticket. This isn't an actual example, but does accurately show how to reproduce the issue)

Foo.php
abstract class Foo
{
    /**
     * @Column(name="first_name")
     */
    protected $firstName;

     /**
     * @Column(name="last_name")
     */
    protected $lastName;
    /**
     * @ORM\Column(name="is_active", type="boolean")
     */
    protected $isActive;
}
Bar.php
/**
 * @Entity
 */
class Bar extends Foo
{
    /**
     * @Id
     * @Column(type="integer")
     * @GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @Column(name="created_at", type="datetime")
     */
    protected $createdAt;
}

Using a setup similar to the above, where Bar extends Foo, there is an issue with the Generator.

1) The generator is redeclaring Foo's properties, as private variables, in Bar

So, opening Bar after running the generator, shows the getters and setters, but shows:
private $firstName;
private $lastName;
private $isActive;

This causes issues because the properties are being recreated as local versions, and their scope is set to private, conflicted with the more open protected version in the abstract class. To me, they shouldn't be placed in Bar because they're declared as protected in Foo and thus Bar has access to them. Also, when they are placed in Bar, the file formatting is messed up around them, suggesting that they were mis-placed in the file.

2) This may or may not be a bug (it may be intended behavior), but... I would think that when running the generator, the getters and setters for the protected properties declared in Foo would be placed in Foo, and not placed in the class(es) that extend Foo (in this case, Bar). If I also have a class Baz that extends Foo, then Bar and Baz will now have copies of the same getFirstName(), getLastName(), and getIsActive() methods, which is unneeded. They can be placed in the parent class, and overridden in the subclasses if more/different functionality/behavior is needed by the subclass.

Hopefully this is a clear example. Please feel free to hit me up for more info!
--mark



 Comments   
Comment by Christoph Schaefer [ 30/Oct/11 ]

I can confirm this behavior.

Before generation:

Foo
/**
 * @ORM\Entity
 * @ORM\HasLifecycleCallbacks
 *
 * @ORM\InheritanceType("JOINED")
 * @ORM\DiscriminatorColumn(name="discr", type="string")
 * @ORM\DiscriminatorMap({"foo_bar" = "FooBar"})
 */
class Foo
{

    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * creation date
     *
     * @ORM\Column(name="created_at",type="datetime")
     */
    protected $createdAt;

    /**
     * getCreatedAt
     *
     * @return \DateTime
     */
    public function getCreatedAt()
    {
        return $this->createdAt;
    }

    /**
     * Set the creation date
     *
     * @return null
     */
    public function setCreatedAt(\DateTime $createdAt)
    {
        $this->createdAt = $createdAt;
    }

    /**
     * @ORM\PrePersist
     */
    public function prePersist()
    {
        $this->createdAt = new \DateTime();
    }
}
FooBar
/**
 * @ORM\Entity
 */
class FooBar extends Foo {

    /**
     *
     * @ORM\Column(type="string", length=255)
     */
    protected $title;
}

after generation of FooBar:

FooBar
/**
 * @ORM\Entity
 */
class FooBar extends Foo {

    /**
     *
     * @ORM\Column(type="string", length=255)
     */
    protected $title;

    /**
     * @var integer $id
     */
    private $id;

    /**
     * @var datetime $createdAt
     */
    private $createdAt;

    /**
     * Set title
     *
     * @param string $title
     */
    public function setTitle($title)
    {
        $this->title = $title;
    }

    /**
     * Get title
     *
     * @return string 
     */
    public function getTitle()
    {
        return $this->title;
    }

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set createdAt
     *
     * @param datetime $createdAt
     */
    public function setCreatedAt($createdAt)
    {
        $this->createdAt = $createdAt;
    }

    /**
     * Get createdAt
     *
     * @return datetime 
     */
    public function getCreatedAt()
    {
        return $this->createdAt;
    }
}

It looks like the generator doesn't check if an attribute is inherited and therefore is already defined.
If an attribute is found as inherited, the generation of the attribute, accessor and mutator should be skipped.

This bug is really annoying, especially when working with bigger objects.

Tested within Symfony2 v2.0.4

doctrine-common]
    git=http://github.com/doctrine/common.git
    version=2.1.2

[doctrine-dbal]
    git=http://github.com/doctrine/dbal.git
    version=2.1.3

[doctrine]
    git=http://github.com/doctrine/doctrine2.git
    version=2.1.2

-Chris

Comment by Benjamin Eberlei [ 09/Jan/12 ]

As per the help message of the entity generation inheritance generation is not yet supported and will not work.

Its planned for 2.3.

Follow DDC-1590 for current information.

Comment by Doctrine Bot [ 05/Aug/14 ]

A related Github Pull-Request [GH-1098] was assigned:
https://github.com/doctrine/doctrine2/pull/1098

Comment by Doctrine Bot [ 18/Aug/14 ]

A related Github Pull-Request [GH-1098] was closed:
https://github.com/doctrine/doctrine2/pull/1098

Comment by Doctrine Bot [ 28/Dec/14 ]

A related Github Pull-Request [GH-1231] was assigned:
https://github.com/doctrine/doctrine2/pull/1231

Comment by Doctrine Bot [ 17/Jan/15 ]

A related Github Pull-Request [GH-1231] was merged:
https://github.com/doctrine/doctrine2/pull/1231





[DDC-3514] LimitSubqueryOutputWalker should not duplicate orderBy clauses Created: 17/Jan/15  Updated: 17/Jan/15  Resolved: 17/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL, Tools
Affects Version/s: Git Master, 2.4.7
Fix Version/s: 2.5
Security Level: All

Type: Improvement Priority: Major
Reporter: Marco Pivetta Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: limitsubqueryoutputwalker, orderBy, orderby, paginator, performance, subquery


 Description   

This issue is just tracking https://github.com/doctrine/doctrine2/pull/1220






[DDC-349] Add support for specifying precedence in joins in DQL Created: 18/Feb/10  Updated: 17/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: 2.0-ALPHA4
Fix Version/s: None
Security Level: All

Type: Improvement Priority: Major
Reporter: Dennis Verspuij Assignee: Roman S. Borschel
Resolution: Unresolved Votes: 1
Labels: None

Attachments: Text File DDC349Test.patch    
Issue Links:
Duplicate
is duplicated by DDC-1256 Generated SQL error with DQL WITH and... Resolved
Reference
is referenced by DDC-3500 [GH-1254] Fix applying ON/WITH condit... Resolved

 Description   

This request is in followup to my doctrine-user message "Doctrine 2.0: Nested joins'.
I am a bit surprised by the responses in that defining precedences in joins by placing parenthesis around join expressions is not well-known. Although not in the original SQL92 specification it is a major and important feature offered by all the RDBMS's that Doctrine 2 supports, and oftenly performs better than using subselects or alike. Doctrine 1 did not support it, but imho Doctrine 2 should support it to be a mature allround ORM.

As a short example the following is a SQL statement with a nested join, where the nesting is absolutely necessary to return only a's together with either both b's and c's or no b's and c's at all:

SELECT *
FROM a A
LEFT JOIN (
b B
INNER JOIN c C ON C.b_id = B.id
) ON B.a_id = A.id

In order for Doctrine 2 to support this the BNF should be something like:
Join ::= ["LEFT" ["OUTER"] | "INNER"] "JOIN" ( "(" JoinAssociationPathExpression ["AS"] AliasIdentificationVariable Join ")" | JoinAssociationPathExpression ["AS"] AliasIdentificationVariable ) [("ON" | "WITH") ConditionalExpression]
instead of the current:
Join ::= ["LEFT" ["OUTER"] | "INNER"] "JOIN" JoinAssociationPathExpression ["AS"] AliasIdentificationVariable [("ON" | "WITH") ConditionalExpression]

This would allow DQL like:

SELECT A, B, C
FROM a A
LEFT JOIN (
A.b B
INNER JOIN B.c C
) WITH B.something = 'value' AND C.something = 'othervalue'

What further needs to be done is that the DQL parser loosly couples the ConditionalExpression to any of the previously parsed JoinAssociationPathExpression's instead of tieing it explicitely to the JoinAssociationPathExpression that preceedes it according to the old BNF notation. The new BNF should however not require any changes to the hydrator. Therefore I have the feeling that improving the DQL parser for nested joins does not require extensive work, while the benefit of running these kind of queries is considerable.

As an extra substantiation here are links to (BNF) FROM clause documentations of the RDBMS's that Doctrine 2 supports, they all show support for nested joins:
MySQL: http://dev.mysql.com/doc/refman/5.0/en/join.html
PostgreSQL: http://www.postgresql.org/docs/8.4/interactive/sql-select.html#SQL-FROM and http://www.postgresql.org/docs/8.1/interactive/explicit-joins.html
MSSQL: http://msdn.microsoft.com/en-us/library/ms177634.aspx
Oracle: http://download.oracle.com/docs/cd/E11882_01/server.112/e10592/statements_10002.htm#CHDDCHGF
SQLite: http://www.sqlite.org/syntaxdiagrams.html#single-source

I surely hope you will consider implementing this improvement because it would save me and others from the hassle of writing raw SQL queries or executing multiple (thus slow) queries in DQL for doing the same. Thanks anyway for the great product so far!



 Comments   
Comment by Guilherme Blanco [ 13/Apr/10 ]

This seems to be a valid issue to me.

This implementation is the actual solution to associations retrieval that are inherited (type joined).

Example:

/** Joined */
class Base {}

class Foo extends Base {}

class Bar {
    public $foo;
}

// This causes the CTI to link as INNER JOIN, which makes the result become 0
// il if you have no Foo's defined (although it should ignore this)
$q = $this->_em->createQuery('SELECT b, f FROM Bar b LEFT JOIN b.foo f'); 
Comment by Roman S. Borschel [ 13/Apr/10 ]

Yes, this is a possible solution for DDC-512 but on the SQL level. I still don't see this as appropriate for DQL, it just doesnt make sense to me, DQL joins object associations, there is no precedence.

Comment by Roman S. Borschel [ 13/Apr/10 ]

So, no, this has nothing to do with DDC-512. DDC-512 can even be fixed differently as outlined in my comments there.

Comment by Roman S. Borschel [ 13/Apr/10 ]

On a side note I would still like to know/see the following for this issue:

  • Some realisitic DQL examples where this feature would be essential, i.e. there is no other way to do it.
    This also means explaining what the impact on the resulting object graph is and why it makes sense.
  • Which other ORMs support this on the OQL/Criteria level?

So far, my stance on this issue is:

1) It doesnt make sense (semantically) in DQL
2) Its rarely needed
3) When you really need it you can use a NativeQuery anyway and use this nesting in SQL, where it probably belongs and makes more sense
4) It would (unnecessarily) complicate DQL

Thus I am currently leaning towards "Wont fix" for this issue.

Comment by Dennis Verspuij [ 13/Apr/10 ]

Hi Roman. I understand your doubts, and I have been breaking my head over
creating a realistic example the last few hours that would hopefully convince
you for implementing this feature. But actually I cannot find one that you wouldn't
consider to be trivial. I do have a number of very complex optimized queries written
for sportskickoff dot com (using Doctrine 1.2) but they are probably hard to understand
because they may not be selfdescribing. Below is one example literally ripped from
the application. Still they often can be broken down to my example query in this
ticket's description, but applied grouping, additional other joins on the root component
and/or other criteria made them impossible to rewrite using subselects or choosing
another root component. Most often they just performed way best using the nested
syntax and saved me a number of additional queries.

SELECT A.id, A.username, A.balance, COALESCE(SUM(B.stake), 0) AS sumstake, COUNT(B.id) AS nrbets
FROM account A
LEFT JOIN (
bet B
INNER JOIN game G ON G.id = :GAMEID AND B.timestampcompletion BETWEEN G.timestampstart AND G.timestampend
) ON B.accountid = A.id AND B.timestampcompletion IS NOT NULL
WHERE A.Status & :ACTIVEORDISQUALIFIED = :ACTIVE
GROUP BY A.id, A.username, A.balance
ORDER BY A.balance DESC, sumstake ASC, nrbets ASC, A.username ASC

But let's put it another way. I would also like this feature to be supported in DQL
because I just do not want to use native queries. Why would I want to use native
queries if it can be done using DQL? In DQL I work with class names and field
names, and they may differ from the underlying table and column names. Doctrine
takes care of that mapping based on my schema/annotations and I do not
have to "know" these mappings. In native queries I suddenly do have to "know"
these mappings. I use Doctrine because it makes my application portable and
enables me to work with my database in an OOP way like I do in my model,
abstracting things. The need for native queries partly reverts the benefits Doctrine
offers in the first place.

Btw, I recall to have successfully used the nested join syntax in HQL (.NET Hibernate)
but I cannot find examples on the web or a BNF notation.

Furthermore, in reply to your stances:
1) It indeed doesnt make sense (semantically) in DQL, it only makes the result
set different, but not the way data is hydrated into objects;
2) Its indeed rarely needed for inserting, updating and populating basic lists but
it allows you to better select what combinations of associated rows are joined
and which not in more optimized queries without having to use native queries,
or because they perform better than using subseletcs and alike.
3) Not having to use native queries is just an extra reason for using Doctrine and
maintains the abstraction the ORM provides througout on'es whole application
4) Why would it complicate DQL, if people do not know about or understand
the feature it wouldn't matter because not using parenthesises is the default
way to specify joins?

Well, this is it, can't find any more words to promote and make you enthusiastic.... lol.

Comment by Dennis Verspuij [ 13/Apr/10 ]

Ok, I have not given up yet... , here's a "stupid" example.

Imagine a book store that sells books of various authors and keeps track of those sales.
Let's say you would have an admin page that lists all authors, and for each author
its also shows the books and their sales dates since january 1st, but only for those
books that were actually sold and contain an A in its name. An optimized SQL query
to fetch all the information at once would be something like:

SELECT A., B., S.*
FROM author A
LEFT JOIN (
book B
INNER JOIN sale S ON S.book_id = B.id AND S.dt >= '2010-01-01'
) ON B.author_id = A.id AND A.name LIKE '%A%'

In DQL it would then be something like:

SELECT A., B., S.*
FROM author A
LEFT JOIN (
book B
INNER JOIN sale S WITH S.dt >= '2010-01-01'
) WITH A.name LIKE '%A%'

If the database would contain thousands of books, but sales for just a
few books, this will definitely perform better than using subselects.
Off course one would like to fetch array graphs instead of objects for
further optimization, but this hopefully shows my point.

I have attached a test casefor a similar query, though without the additional
join constraints for clarity. I surely hope you can consider it.

One last note, you shouldn't be afraid that nesting joins is not in the
ansi SQL spec. Select queries are about record sets and products
between these sets, tables are just the basic means of providing record
sets to the query. This is an important terminological difference to think about.
Specifying precedence with parenthesis around joins is a logical and
natural evolution of the ansi sql standard. For example views are a good
proof of this concept, I could define book B INNER JOIN sale S as a view
and LEFT JOIN that to authors to get effectively the same result
set as the above example. The database server would internally perform the
same query (though may additionally take indexes on the view into account).
That said, rdbm's that support this syntax would certainly never drop the
feature, as its not a feature but just plain logical and smart querying!

P.S. I had a hard time finding out how to run the test cases, I could not find
it in the Doctrine 2 documentation, development wiki, cookbook or any other
place, while finally it was as easy as running phpunit Doctrine_Tests_AllTests
from within the tests/ directory, or just phpunit Doctrine_Tests_ORM_Functional_Ticket_DDC349Test
for my test. Could you please add some info about this somewhere, it might
save others some googling.

Comment by Dennis Verspuij [ 13/Apr/10 ]

Test case as SVN patch using a parenthesized join.
Just remove the parenthesises from the query to have it fail...

Comment by Roman S. Borschel [ 29/May/10 ]

@"The need for native queries partly reverts the benefits Doctrine offers in the first place."

That is something I hugely disagree with. Neither SQL abstraction, nor database vendor independence is the main purpose of an ORM like Doctrine 2.
It is the state management of your objects, the transparent change tracking, lazy-loading and synchronization of the object state with the database state and nothing of this gets lost when using native queries.

We could rip out DQL and any other querying mechanism except a basic find() (and lazy-loading, of course), only providing the native query facility and even only supporting MySQL and would still retain all the core ORM functionality.

NativeQuery is one of the best and core "features" of the project. It is even the foundation for DQL. A DQL query is nothing more than an additional (beautiful) abstraction but what comes out is a native query + a ResultSetMapping, the same thing you can build yourself in the first place, even using the mapping metadata to construct the query. Nothing forces you to hardcode table and column names in native queries if you don't want that. Just use the mapping metadata, DQL does the same.

SQL abstraction and database vendor independence is icing on the cake, not the heart of the ORM.





[DDC-2506] WITH Conditionals on Class Table Inheritance LEFT JOINs are inserted incorrectly Created: 14/Jun/13  Updated: 17/Jan/15  Resolved: 20/Aug/13

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: Git Master
Fix Version/s: 2.4, 2.3.5
Security Level: All

Type: Bug Priority: Major
Reporter: Matt Janssen Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 2
Labels: dql, inheritance, joins, sql-walker

Issue Links:
Reference