[DDC-3714] [GH-1394] Fix result cache setting query caching Created: 24/Apr/15  Updated: 24/Apr/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 mente:

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

Message:

Hello!

This PR fixes the issue with result caching option when query caching is on.

Reproduce is pretty easy. Call same query twice: first time with `Query::useResultCache(true)`, second time with `Query::useResultCache(false)`. If query cache is on - `useResultCache()` setting will be cached along with query itself.

Use case is when you want to keep query cache always on but want sometimes to bypass result cache (e.g. you're sure that underlying data was updated).

P.S. Is it possible to backport fix to 2.4? I can provide another PR for it

Alex






[DDC-3713] [GH-1393] Composite key id used in nullable relations Created: 24/Apr/15  Updated: 24/Apr/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 Firemango:

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

Message:

This provides a fix, when you're using a composite primary key, and using part of the composite key as a join column, that will make sure you don't overwrite the composite id key.

Also the fix to Unit of Work needed to consider if part of a composite key was null, it should not try to map the entity.






[DDC-3712] [GH-1392] transactional() wrapper corrupts return values Created: 23/Apr/15  Updated: 23/Apr/15

Status: Awaiting Feedback
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.4, 2.5
Fix Version/s: None
Security Level: All

Type: Bug Priority: Minor
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: entitymanager, transactional


 Description   

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

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

Message:

The EntityManager::transactional() method has undocumented behavior, which unexpectedly rewrites all `false`-ish return values into `true` before passing them on:

    $result = $this->_em->transactional(function (){
        return array();
    }
    assert(is_array($result)); // Fails

I think there's a very strong case to be made that this is undesirable, *however* it's been in existence for a few years now (since DDC-1125) and it's very likely at least a few users have code that relies on the undocumented behavior.

This PR represents the most direct fix, but as a practical matter we may want to improve the documentation instead. If that is the decision, I'd be happy to create a separate PR for documentation changes.






[DDC-3711] Error on manyToMany with composite primary key Created: 23/Apr/15  Updated: 23/Apr/15

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

Type: Bug Priority: Major
Reporter: Marc Pantel Assignee: Marco Pivetta
Resolution: Unresolved Votes: 0
Labels: None
Environment:

symfony 2.6



 Description   

Hi,
I hope that I report in the right place.
I have an issue when I try to create an manyToMany association with an entity with a composite primary key.
The problem is that only one of the two key are create on the association table.

I also have manyToOne association that works fine.

Here are the mapping

Commune.orm.yml

AppDemo\ZoneBundle\Entity\Commune:
    type: entity
    table: ref_commune
    id:
        codeInsee:
            type: string
            nullable: false
            length: 5
            fixed: true
            column: commune_code_insee
        codePostal:
            type: string
            nullable: false
            length: 5
            fixed: true
            column: commune_code_postal
    fields:
        nom:
            type: string
            nullable: false
            length: 100
            fixed: false
            column: commune_nom
    manyToMany:
        zones:
            targetEntity: Zone
            joinTable:
                name: lnk_zone_commune
                joinColumns:
                    commune_code_insee:
                        referencedColumnName: commune_code_insee
                    commune_code_postal:
                        referencedColumnName: commune_code_postal
                inverseJoinColumns:
                    zone_id:
                        referencedColumnName: zone_idx

Zone.orm.yml

AppDemo\ZoneBundle\Entity\Zone:
    type: entity
    repositoryClass: AppDemo\ZoneBundle\Repository\ZoneRepository
    table: ref_zone
    id:
        idx:
            type: integer
            nullable: false
            unsigned: false
            comment: ''
            id: true
            column: zone_idx
            generator:
                strategy: IDENTITY
    fields:
        libelle:
            type: string
            nullable: false
            length: 30
            options:
                default: ''
                comment: 'Libelle de la Zone'


 Comments   
Comment by Marco Pivetta [ 23/Apr/15 ]

What if you simply leave out the joinColumns mappings? Check what comes out of the metadata there, then compare it to your metadata (dump it)

Comment by Marc Pantel [ 23/Apr/15 ]

When I remove the JoinsColumns mapping, I get an error:

Column name `id` referenced for relation from AppBundle\Entity\Commune towards AppBundle\Entity\Zone does not exist.

How do I dump the metadata?





[DDC-3710] Relations inside of embedded objects do not work Created: 23/Apr/15  Updated: 23/Apr/15  Resolved: 23/Apr/15

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

Type: Bug Priority: Major
Reporter: Kore Nordmann Assignee: Marco Pivetta
Resolution: Won't Fix Votes: 0
Labels: embeddables, orm

Attachments: File ValueObjectsWithRelationTest.php    

 Description   

If an embeddable has a relation to another object this is neither stored nor fetched.

Find attached a test case showing and reproducing the problem with a Many-To-One relation inside an embeddable.



 Comments   
Comment by Marco Pivetta [ 23/Apr/15 ]

A value object can't have an object reference to an entity by design, as checking its value would then be impossible from the outside (because a VO can't reference a non-VO)





[DDC-3709] [GH-1391] [DDC-3693] Issue with notify change tracking policy Created: 22/Apr/15  Updated: 22/Apr/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 napsi:

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

Message:






[DDC-3700] orderBy stopped working after upgrading to 2.5v (Column not found error) Created: 19/Apr/15  Updated: 22/Apr/15

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

Type: Bug Priority: Major
Reporter: Khurshid Yalgashev Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: orderBy
Environment:

ubuntu 14.04


Attachments: JPEG File sl_notification.jpg    

 Description   

Hi,
I have this very simple method in my repository class which fetches a list as query builder object:

public function fetchListAsQueryBuilder(User $user, $receiverType, $limit, $offset)
{
    $queryBuilder = $this->getEntityManager()->createQueryBuilder();
    $query = $queryBuilder
        ->select(['no'])
        ->from('SLCoreBundle:Notification', 'no')
        ->where('no.receiver = :user')
        ->andWhere('no.receiverType = :receiverType')
        ->orderBy('no.createdAt', 'DESC')
        ->setParameters([
            'user' => $user,
            'receiverType' => $receiverType,
        ])
        ->setMaxResults($limit)
        ->setFirstResult($offset)
    ;

    return $query;
}

After upgrading to v2.5 it stopped working and is giving this error:

An exception occurred while executing 'SELECT DISTINCT id_6 FROM (SELECT s0_.receiver_type AS receiver_type_0, s0_.importance AS importance_1, s0_.seen AS seen_2, s0_.deleted AS deleted_3, s0_.created_at AS created_at_4, s0_.updated_at AS updated_at_5, s0_.id AS id_6, s0_.reason AS reason_7 FROM sl_notification s0_ WHERE s0_.receiver_id = ? AND s0_.receiver_type = ?) dctrn_result ORDER BY s0_.created_at DESC LIMIT 25 OFFSET 0' with params [2, 1]:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 's0_.created_at' in 'order clause'

My entity has been configured like this:

Mapped superclass AbstractMessage:

abstract class AbstractMessage
{
    use CreatedUpdatedAtTrait;

    // here go properties, setters and getter

Notification class:

class Notification extends AbstractMessage
{
    // here go properties, setters and getters

And CreateUpdatedAtTrait:

trait CreatedUpdatedAtTrait
{
    /**
     * @var \DateTime
     */
    private $createdAt;

    /**
     * @var \DateTime
     */
    private $updatedAt;

    // Here go setters and getters
}

Schema (AbstractMessage) :

<mapped-superclass name="SL\CoreBundle\Entity\AbstractMessage">

    ... 

    <field name="createdAt" column="created_at" type="datetime">
        <gedmo:timestampable on="create" />
    </field>

    <field name="updatedAt" column="updated_at" type="datetime">
        <gedmo:timestampable on="update" />
    </field>

</mapped-superclass>

I'dont understand what causes this error, my others entities work well with this trait, and also my other queries with orderBy method and mappedsuperclass classes work without any error. And also very interesting part is if I remove orderBy my method is working and I am able to get the createdAt value ($object->getCreatedAt()).

PS// Reference: http://stackoverflow.com/questions/29715104/error-with-orderby-column-not-found






[DDC-3708] Doctrine SQL filters and lazy loading causing EntityNotFoundException Created: 22/Apr/15  Updated: 22/Apr/15

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

Type: Documentation Priority: Minor
Reporter: Pavle Predic Assignee: Marco Pivetta
Resolution: Unresolved Votes: 0
Labels: None


 Description   

When using a global SQL filter, lazy loading ManyToOne relations may lead to an EntityNotFoundException. You will always get a proxy object for the relation, but as soon as you try to access any property, doctrine will attempt to load the entity from DB, get zero results because the global filter has been applied (assuming that the filter affects the entity in question) and throw an EntityNotFoundException.

What is the recommended way of dealing with this issue globally? The use case is a CMS with a soft-delete feature. A global sql filter filters out entities with a deleted flag. One solution would be to write a custom ProxyFactory that doesn't throw the EntityNotFoundException or to write a custom ProxyGenerator that puts the initializer call in a try/catch block and returns null if an EntityNotFoundException is thrown.

This issue can be resolved by using "fetch EAGER" on ManyToOne relations, but this can lead to performance issues due to the large number of DB queries. How can this problem be solved while still using the lazy loading mechanism?



 Comments   
Comment by Marco Pivetta [ 22/Apr/15 ]

This sort of issue simply occurs when enabling SQL filters after any loading has already happened.

We can't fix this, you are supposed to call Doctrine\ORM\EntityManagerInterface#clear() right after enabling or disabling any filter.

Comment by Pavle Predic [ 22/Apr/15 ]

Filter is enabled from the start. I'm not sure if I managed to explain the issue properly, so let's use an example. Say we have the following entities:

Person (id, name, image_id, deleted)
Image (id, file_name, deleted)

Image is defined as a ManyToOne relation in Person.

Now let's say we have a global SQL filter that filters out all entities where deleted = 1.
Say we have the following data:
Person table:

1, "Jimi", 1, 0

Image table:

1, "jimi.jpg", 1

Now I load the person:

$person = $personRepository->find(1);

If I now access the related Image entity, I will get the instance of Proxy class:

$image = $person->getImage(); //no errors here, doctrine assumes that the relation exists, but doesn't attempt to load it from DB

When I try to get a specific Image attribute, I get an EntityNotFoundException:

$imagePath = $image->getFileName(); //throws an EntityNotFoundException

Obviously, I could use a try/catch block here, but I need a global solution. Most of the time, I'm accessing such relations in a twig template, which is not the best place to deal with exceptions.

Comment by Marco Pivetta [ 22/Apr/15 ]

Reopened: I obviously misunderstood the problem.

I don't think there is a doctrine-side solution to it.

Comment by Pavle Predic [ 22/Apr/15 ]

So definitely not possible to extend ProxyFactory or ProxyGenerator?

Or can this be made into a feature request where a specific config option would force the Proxy to return null instead of throwing an EntityNotFoundException?

Comment by Marco Pivetta [ 22/Apr/15 ]

Since it is an SQL-level filter, it would have to act at SQL level.

One possible solution is to always do joins on filtered associations, and then fetch either NULL or the identifier for those associations.





[DDC-3707] Getting Started contains a broken link Created: 21/Apr/15  Updated: 21/Apr/15

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

Type: Documentation Priority: Minor
Reporter: Chris Smith Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: 404, documentation


 Description   

The reference to Zend DB is broken in the getting started documentation.



 Comments   
Comment by Chris Smith [ 21/Apr/15 ]

I think it should point to here: http://framework.zend.com/manual/1.12/en/zend.db.table.html





[DDC-3706] DQL parsing fail when using COUNT with "Simple Derived Identity" primary key Created: 21/Apr/15  Updated: 21/Apr/15

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

Type: Bug Priority: Major
Reporter: Dmitry Korotovsky Assignee: Marco Pivetta
Resolution: Unresolved Votes: 0
Labels: bidirectional, count, onetoone, parser
Environment:

Mac osx Maverick
PHP 5.5.13
Nginx 1.6.0
Mysql 5.6.19


Attachments: File DDC3331Test.php    

 Description   

There is the regression https://github.com/doctrine/doctrine2/commit/097840dc935e1cfbc93fc673be077a8fe67e8e52

commit 097840dc935e1cfbc93fc673be077a8fe67e8e52
Author: Marco Pivetta <ocramius@gmail.com>
Date: Wed Aug 27 01:56:11 2014 +0200

Allowing expression in `COUNT()` DQL aggregation functions

:040000 040000 5d5f12583a38f54e5966b1cb65dfe487d932a728 982b2c8642e311730b48c6e5d6e6740c97e3bd5c M lib

On Doctrine 2.5.0 FOSElasticaBundle doesn't work completely

$ php app/console fos:elastica:populate --env=test
Resetting users
Refreshing users

[Doctrine\ORM\Query\QueryException]
[Semantical Error] line 0, col 13 near 'a) FROM F\Q\C\N\Entity\UserProfile': Error: Invalid PathExpression. Must be a StateFieldPathExpression.

[Doctrine\ORM\Query\QueryException]
SELECT COUNT(a) FROM F\Q\C\N\Entity\UserProfile a






[DDC-3705] Order by With Equals is not supported Created: 20/Apr/15  Updated: 20/Apr/15

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

Type: Bug Priority: Major
Reporter: Alexey Kosov Assignee: Guilherme Blanco
Resolution: Unresolved Votes: 0
Labels: dql


 Description   

Related to this issue: http://www.doctrine-project.org/jira/browse/DDC-2204
Solution proposed by Benjamin Eberlei doesn't work so the issue it still unresolved.

SELECT
e.status = 1 AS HIDDEN orderField
FROM
Entity e
ORDER BY
orderField DESC

Doctrine\ORM\Query\QueryException
\vendor\doctrine\orm\lib\Doctrine\ORM\Query\QueryException.php:52
[Syntax Error] line 0, col 47: Error: Expected Doctrine\ORM\Query\Lexer::T_FROM, got '='






[DDC-2204] Order by With Equals is not supported Created: 17/Dec/12  Updated: 20/Apr/15  Resolved: 22/Dec/12

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

Type: Bug Priority: Critical
Reporter: Ilya Biryukov Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: dql
Environment:

SQL construct tested on postgres 9.0, mysql 5.5, and sqlite 3.


Attachments: File Language.sql    

 Description   

The sample query (I want to bring a specific item to the top of the list).
mysql> select * from Language order by name='English' desc, name asc limit 5;
------------+

id name

------------+

82 English
73 Albanian
74 Arabic
75 Armenian
76 Bengali

------------+
5 rows in set (0.00 sec)

In theory, the code below should generate the same query.
$repository->createQueryBuilder('p')
->addOrderBy("p.name='english'", 'desc')
->addOrderBy('p.name', 'asc');

In practice, an exception is thrown.
Doctrine\ORM\Query\QueryException: [Syntax Error] line 0, col 67: Error: Expected end of string, got '=' (uncaught exception) at /vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php line 44

Attached, SQL dump for the table & data



 Comments   
Comment by Benjamin Eberlei [ 22/Dec/12 ]

Its supported by including the condition in the SELECT clause, aliasing it, then using it. You might need to use "AS HIDDEN name" to prevent it from appearing in the result

Comment by Alexey Kosov [ 20/Apr/15 ]

It does not actually work.

http://stackoverflow.com/questions/25761989/doctrine-select-statement-using-equals-not-accepted





[DDC-3704] [GH-1390] Document the ChainCache class Created: 20/Apr/15  Updated: 20/Apr/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 deviantintegral:

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

Message:

I was thisclose to writing a ChainCache class myself, and only avoided it by actually looking in the source. There's no mention of ChainCache on Google, probably because there's no docs for it. ChainCache is a bit different from other drivers in that it's something implementers will want to use in their own code in place of an ArrayCache or static array. However, I also added a link to the cache drivers given there's quite a few that aren't mentioned in the docs.






[DDC-3703] [GH-1389] Fix Lexer::match() so it does not accept T_WHERE when T_WITH is supposed to be matched Created: 19/Apr/15  Updated: 19/Apr/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 mpdude:

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

Message:

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



 Comments   
Comment by Matthias Pigulla [ 19/Apr/15 ]

This is the PR for DDC-3701. Please close or mark as duplicate of DDC-3701, whatever your workflow is.





[DDC-3702] [GH-1388] Fix Lexer::match() so it does not accept T_WHERE when T_WITH is supposed to be matched Created: 19/Apr/15  Updated: 19/Apr/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 mpdude:

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

Message:

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



 Comments   
Comment by Doctrine Bot [ 19/Apr/15 ]

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

Comment by Matthias Pigulla [ 19/Apr/15 ]

Please disregard / close.





[DDC-3701] Questions regarding Parser::match and "identifier" EBNF Created: 19/Apr/15  Updated: 19/Apr/15

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

Type: Bug Priority: Minor
Reporter: Matthias Pigulla Assignee: Guilherme Blanco
Resolution: Unresolved Votes: 0
Labels: None


 Description   

I am currently investigating a problem where I am suspecting the DQL parser to wrongly transform a DQL statement to SQL. While I haven't yet found the exact reason (will open a new case for it), I have come across the following in the Parser::match() method:

   if ($lookaheadType !== $token && $token !== Lexer::T_IDENTIFIER && $lookaheadType <= Lexer::T_IDENTIFIER) {
      $this->syntaxError($this->lexer->getLiteral($token));
   }

The if-condition was changed a while ago in order to allow DQL terms like WHERE to appear as identifiers.

I think that the condition is wrong as it will only fail (create the syntax error) when the actual token does not match the expected type, we're not expecting an "identifier" and the next token is something special like punctuation that could not serve as an identifier.

So, for example when we're match()ing a T_WITH, a T_WHERE will be accepted as well. A correct check would probably not solve my actual problem, but it would probably have been spotted much earlier due to syntax errors issued.

IMO this should actually read

if ($lookaheadType !== $token && ($token !== Lexer::T_IDENTIFIER || $lookaheadType <= Lexer::T_IDENTIFIER)) { ... syntax error ... }

That is, fail if the token does not match the expectation; and when the expectation is T_IDENTIFIER, also accept every terminal string that can also be considered an "identifier".

With this change, the tests almost pass. The only problem is when a FROM clause expects an "identifier" and now a fully qualified class name starting with a backslash is no longer accepted.

Unfortunately, I also did not manage to find an exact definition of "identifier" somewhere in the EBNF. Lexer::getType() considers everything that starts with a character or underscore an identifier, but that does not match FQCNs.

As there seems to be no special token for backslashes, I tried allowing the backslash as a starting character for identifiers as well (in the Lexer), and it seems to work (all non-skipped tests pass).

What do you think about it? Is that something we should fix and does my change make sense?






Generated at Sun Apr 26 13:06:25 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.