### [DDC-2822] Replacing object in a OneToOne with OrphanRemoval=true isn't working as expected Created: 26/Nov/13  Updated: 14/Dec/13

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

 Type: Bug Priority: Blocker Reporter: Felipe Guaycuru Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: orm Environment: PHP 5.4

 Description
 So I have a class defined like this: class PhoneSettings { //[...] /** * @OneToOne(targetEntity="Medium", cascade={"persist", "remove"}, orphanRemoval=true) * @JoinColumn(name="medium_id", referencedColumnName="medium_id", nullable=true, onDelete="SET NULL") **/ protected $medium = null; //[...] }  And class Medium has no reference to the class Settings. Now suppose I have a$Settings object that is already persisted and has been correctly loaded. Also suppose that the $Settings object has a$medium (that is, $Settings->medium =$OldMedium) Now suppose I do: $Settings->medium =$NewMedium; Where $NewMedium is a different Medium object. When I persist$Settings, Doctrine does delete $OldMedium from the DB, but the problem is that it also deletes$NewMedium ... I have tried removing onDelete="SET NULL", but then I receive a "cannot delete, constraint failed" error...

### [DDC-2237] oracle IN statement with more than 1000 values Created: 11/Jan/13  Updated: 02/Apr/13

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

 Type: Bug Priority: Critical Reporter: Marc Drolet Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description
 If I have a query with a IN statement with more tahn 1000 values I get an sql error. I've try IN with implode: select * from test where id IN(' . implode(',', $values) . ') and I've also try with executeQuery: select * from test where id IN(:test) executeQuery($sql, array($values), array(\Doctrine\DBAL\Connection::PARAM_INT_ARRAY))  Comments  Comment by Marc Drolet [ 11/Jan/13 ] Here is the way I've implement the solution on my side: (for oracle) into Doctrine/DBAL/Statement.php, I've add this method: /** * Binds a parameter value to the statement. * This is implemented this way for oracle only. Other drivers are redirected to bindValue method. * * The value will be bound with to the type provided (that required to be a table type). * * @param String$name The name or position of the parameter. * @param Array $value The value of the parameter. * @param String$type The name of the type to use to bind. * @return boolean TRUE on success, FALSE on failure. */ public function bindList($name, Array$value, $type) { if ('oracle' !==$this->platform->getName()) { $this->bindValue($name, $value,$type); } else { return $this->stmt->bindList($name, $value,$type); } }  into Doctrine/DBAL/Driver/Statement.php I've add: /** * @TODO: docs */ function bindList($param, Array$values, $type);  into Doctrine/DBAL/Driver/OCI8/OCI8Statement.php I've add this method: /** * {@inheritdoc} */ public function bindList($param, Array $value,$type) { if (!($list = oci_new_collection($this->_dbh, $type))) { //throw new OCI8Exception::fromErrorInfo($this->errorInfo()); } foreach ($value as$entry) { $list->append($entry); } if (!oci_bind_by_name($this->_sth,$param, $list, -1, OCI_B_NTY)) { //throw new OCI8Exception::fromErrorInfo($this->errorInfo()); } }  // NOTE: we should probably add the bindList to all driver Statement object. into your code you can use it this way: $sql = " SELECT * FROM test WHERE id IN ( SELECT * FROM ( CAST (: p_ids AS list_int_type) ) ) ";$stmt = connection->prepare($sql);$stmt->bindList(': p_ids', $ids, 'list_int_type');$stmt->execute(); $rs =$stmt->fetchAll(PDO::FETCH_ASSOC);  NOTE: list_int_type need to be a valid oracle data type. You can create one with the name you want. example: you can have 2 type of accepted array of values: integer and string let's say we create one for string named: list_str_type and one for integer list_int_type create or replace type list_str_type as table of varchar2(4000); create or replace type list_int_type as table of number; Comment by Benjamin Eberlei [ 01/Apr/13 ] Hey Marc Drolet thanks for the feedback and the solution, however i would like to have something generic that is working independent of the database driver. This code is very specific. Can you point me to some documentation why oci collection works with more than 1000 elements and how it works in PHP? Comment by Marc Drolet [ 02/Apr/13 ] Hi Benjamin, The limitation is not from the oci driver, it's an oracle limitation. There are a couple of possible solution/implementation that can be done but the one I've provide is the one that perform better for the test I've done and from what I can found over the blogs I've read. I can't find the exact documentation of oracle. oracle doc is so poor. Here is the best description link I can provide that describe some possible implementation. http://vsadilovskiy.wordpress.com/substituting-a-collection-for-in-list-performance-study/ I don't know if there is similar limitation with other database. With the implementation I've provided, It will be possible to implement the proper solution depending on the database limitation you face otherwise it will execute the generic IN. What's bad, we need to create the type into the database. NOTE: In my case, I can not perform a sub-query, I get the my collection from a web service call.

### [DDC-2624] ManyToManyPersister fails to handle cloned PeristentCollections Created: 20/Aug/13  Updated: 18/Nov/13

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

 Type: Bug Priority: Critical Reporter: Martin Prebio Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 1 Labels: None

 Description
 I want to clone an entity and persist the clone. The entity itself works (if I reset the identifiers to null) but a M2M collection was first ignored since I only did a shallow copy. When I do a deep copy with the following, Doctrine throws the following exception: public function __clone() { if ($this->question_versions instanceof PersistentCollection) {$this->question_versions = clone $this->question_versions; } } Fatal error: Uncaught exception 'Doctrine\Common\Persistence\Mapping\MappingException' with message 'The class 'Doctrine\ORM\Persisters\ManyToManyPersister' was not found in the chain configured namespaces Foo\Entity' in /var/www/foo/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php on line 37 I've traced the error to the ManyToManyPersister class at the methods get {Delete,Insert} RowSQL where$coll->getOwner() is called which returns null because the owner is cleared when the collection is cloned. Therefore get_class does not work as expected under this circumstances. I've also tried to use $coll->getTypeClass() for$class at that point but this leads to other warnings ("array key not existing" and "spl_object hash got null") and finally an SQL exception because Doctrine is inserting null as one of the identifiers. There is a workaround for this issue but I think that this edge case should be handled too. The workaround is not to clone the collection itself but only copy the values with getValues() and let Doctrine convert it back to a collection.

 Comment by Martin Prebio [ 20/Aug/13 ] This issue may be related to DDC-2074 Comment by Marcin Iwański [ 18/Nov/13 ] I have the same problem on v2.4.1 after cloning collections in __clone() method of the entity, so seems that DDC-2074 didnt fix this case. But collection cloning is needed to properly manage cloned entity relationships. Comment by Martin Prebio [ 18/Nov/13 ] The getValues() workaround created some issues for us but I found another workaround. This one works for us for some time in a small to medium sized project where we heavily clone, detach and so on: __clone() { if ($this->m2mcoll instanceof PersistentCollection) {$this->m2mcoll = clone $this->m2mcoll;$this->m2mcoll->setOwner($this,$this->m2mcoll->getMapping()); } } The problem here is that this can not be put into the collection's clone method since it requires the entity object (which is $this). Comment by Marcin Iwański [ 18/Nov/13 ] Thanks Martin for your help, your workaround seems to work well in my case. I dont know yet if it has any drawbacks that may occur in longer time period. My general thought after dealing with entity cloning is that official manual should pay more attention to this topic, because I had to figure out most of the issues by myself. Comment by Martin Prebio [ 18/Nov/13 ] Yes, I've made the same experience regarding the documentation but still I haven't found time to contribute to it. Nevertheless if you run in any problems with my new workaround, please let me know of it. (I already spent some hours in the Doctrine code for some other issues) ### [DDC-2800] Something wrong with documentation generation Created: 18/Nov/13 Updated: 18/Nov/13 Status: Open Project: Doctrine 2 - ORM Component/s: None Affects Version/s: None Fix Version/s: None Security Level: All  Type: Documentation Priority: Critical Reporter: Flip Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None  Description  The ArrayCollection has a matching() function, but it does not show in the API docs. http://www.doctrine-project.org/api/common/2.4/class-Doctrine.Common.Collections.ArrayCollection.html ### [DDC-2863] multiple oneToMany entity relations not working, unless specified under one sigle oneToMany entry Created: 18/Dec/13 Updated: 19/Dec/13 Status: Open Project: Doctrine 2 - ORM Component/s: ORM Affects Version/s: None Fix Version/s: None Security Level: All  Type: Bug Priority: Critical Reporter: Nopcea Francisc Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None  Description  this does not work: oneToOne: user: targetEntity: Project\Entity\User mappedBy: settings oneToOne: language: targetEntity: Project\Entity\Language joinColumn: name: language_id referencedColumnName: id  and this works:  oneToOne: user: targetEntity: Project\Entity\User mappedBy: settings language: targetEntity: Project\Entity\Language joinColumn: name: language_id referencedColumnName: id  while the latter is nicer, I don't see why the first one should not work. Also, this situation should have been prevented in the documentation. ### [DDC-851] Automerge of detached entities passed to doctrine Created: 31/Oct/10 Updated: 30/Dec/10 Status: Open Project: Doctrine 2 - ORM Component/s: ORM Affects Version/s: 2.0-BETA4 Fix Version/s: None Security Level: All  Type: Improvement Priority: Major Reporter: Daniel Alvarez Arribas Assignee: Roman S. Borschel Resolution: Unresolved Votes: 0 Labels: None  Description  This is a feature request. Currently it is not possible to assign a detached entity to a relationship. You have to manually "merge" it, and only then you are able to assign it to relationships of managed objects. This can become complicated to do. The way it is now, when assigning an entity to a relationship in a process using a large number of entities, the entity's state needs to be checked and the entity possibly merged - all in userland code. This adds a level of complexity and potential for errors, while it could be solved transparently and elegantly within the ORM. There are ways to implement it in userland code, too, with moderate effort (see below), but this does not change the fact that responsibility for implementing a purely technical feature is delegated to the user, who could be spending his time much better writing business code. And if the user actually implements it, it will clutter the application with non-problem-domain code. To keep things simple, I propose Doctrine be extended to simply auto-merge any detached entities passed to it. That would save the programmer the manual tracking of object states and merge() calls. This would be especially handy when using cascades, as keeping track of deep object graphs in userland code would duplicate substantial ORM functionality. In programs that work with massive amounts of data, it is practically impossible to keep all entities managed due to resource constraints (see e.g. the batch processing patterns documented in the Doctrine 2 reference at http://www.doctrine-project.org/projects/orm/2.0/docs/reference/batch-processing/en). In a situation like that, one would probably simply flush and clear the entity manager regularly. Doctrine 2 currently forces the user to manually "merge" all persistent objects he/she still holds references to and wants to assign e.g. to other newly created persistable objects. I can not think of any reason why Doctrine 2 should not be able to do it automatically. Below is another comment originally attached to the GitHub proposal, containing a userland implementation of the feature as a temporary fix, for whoever cares. Here is a userland implementation for the functionality I am proposing, though I feel it is technical clutter that belongs into the ORM. Changing doctrine to be able to auto-merge unmanaged entities would be ideal. I thought I'd share this, for use as long as Doctrine 2 does not provide equivalent functionality. The implementation assumes all entities inherit from a base class (named "YourEntityBaseClass here") and intercepts the assignment to ToOne-relationships in a __set() method provided in that base class. For ToMany-relationships we extend ArrayCollection to intercept calls to add() and set() to accomplish the same. As an alternative to defining a __set() method in a base class you could also implement the interception by changing any mutator methods you define in your entities. But that would bloat your code quickly as you define more and more relationship attributes on your entities. The following __set() method implementation relies on reflection to parse the DocBlock-Comment with the Annotation and determine whether or not the property to be set is a ToOne-relationship.  public function __set($name, &$value) {$reflectionClass = new ReflectionClass($this);$property = $reflectionClass->getProperty($name); if ( self::isToOneRelationship($property) &&$value !== null) { $value = self::mergeIfDetached($value); } $this->$name = $value; }  The following is an implementation of mergeIfDetached(), that assumes there is a __get defined on the entity, to be able to access the protected mapped properties. public static function mergeIfDetached(YourEntityBaseClass$dataObject) { $doctrineEntityManager = DB::getDoctrineEntityManager(); if ($doctrineEntityManager->getUnitOfWork()->getEntityState($dataObject) == \Doctrine\ORM\UnitOfWork::STATE_DETACHED) {$dataObject = $doctrineEntityManager->merge($dataObject); } return $dataObject; }  For your purposes, consider DB to be just a class holding a reference to the Doctrine entity manager. Here are the helper methods for the reflection:  private static function isToOneRelationship(ReflectionProperty$property) { return self::matchDoctrineAnnotation($property, self::$doctrineToOneRelationshipAnnotation); } private static function matchDoctrineAnnotation(ReflectionProperty $property,$pattern) { return preg_match('/\@' . $pattern . '/',$property->getDocComment()) != 0; }  Here is the drop-in-replacement class for use with ToMany-Relationships. It uses the static reloadIfDetached method defined in the entity base class: use Doctrine\Common\Collections\ArrayCollection; class Collection extends ArrayCollection { public function set($key,$value) { $value = YourEntityBaseClass::mergeIfDetached($value); parent::set($key,$value); } public function add($value) {$value = YourEntityBaseClass::mergeIfDetached($value); return parent::add($value); } }  This approach keeps the amount of unnecessary code to a minimum, so that merges are not scattered throughout the problem-domain code.

 Comment by Daniel Alvarez Arribas [ 29/Dec/10 ] I have to note that the code I listed above turned out to be broken. There is nothing that guarantees that a data object just merged will not become detached again after being merged on assignment, unless the object is immediately persisted afterwards. The correct solution would be to merge all data objects found through relationships for a given data object, right from the persistence manager, immediately before calling persist() on the data object. I am currently using this solution (save() saves a data object safely for use within long-running batch jobs):  public static function save(DataObject $dataObject) { self::mergeRelatedDataObjectsIfDetached($dataObject); self::$doctrineEntityManager->persist($dataObject); } public static function merge(DataObject $dataObject) { return self::$doctrineEntityManager->merge($dataObject); } protected static function mergeRelatedDataObjectsIfDetached(DataObject$dataObject) { $reflectionClass = new ReflectionClass($dataObject); $properties =$reflectionClass->getProperties(); foreach ($properties as$property) { $propertyName =$property->getName(); $propertyValue =$dataObject->__get($propertyName); if (MetadataReader::isToOneRelationship($property)) { if ( $propertyValue !== null && !$propertyValue instanceof Proxy && self::isDetached($propertyValue)) {$relatedDataObject = self::merge($propertyValue);$dataObject->__set($propertyName,$relatedDataObject); } } else { if (MetadataReader::isToManyRelationship($property)) {$relatedDataObjects = $propertyValue->toArray(); foreach ($relatedDataObjects as $index =>$relatedDataObject) { if ( ! $relatedDataObject instanceof Proxy && self::isDetached($relatedDataObject)) { $relatedDataObject = self::merge($relatedDataObject); // Replace the entry in the collection with the merged copy. $propertyValue->set($index, $relatedDataObject); } } } } } } protected static function isDetached(DataObject$dataObject) { return self::$doctrineEntityManager->getUnitOfWork()->getEntityState($dataObject) == UnitOfWork::STATE_DETACHED; }  I still wish there would be an automerge feature, kind of Hibernate's "update". Comment by Daniel Alvarez Arribas [ 29/Dec/10 ] Wrapped the code sections into proper code blocks...

### [DDC-813] Validate Schema should complain on bi-directional relationships with mapped superclasses Created: 21/Sep/10  Updated: 29/Oct/12

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

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

 Description
 @ManyToOne and @OneToOne on mapped superclasses have to be unidirectional. The Schema Validator should verify this.

### [DDC-810] Issue with detaching entities and updating when using change notification Created: 17/Sep/10  Updated: 04/Jul/11

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

 Type: Improvement Priority: Major Reporter: Jonathan H. Wage Assignee: Roman S. Borschel Resolution: Unresolved Votes: 0 Labels: None

 Attachments: DDC810Test.php

 Description

 Comment by Benjamin Eberlei [ 20/Sep/10 ] From reading the issue i know what the bug is, indeed this sucks. Comment by Roman S. Borschel [ 28/Sep/10 ] @Jon: Any more information coming? @Benjamin: Can you summarize the essence of the issue shortly? Comment by Benjamin Eberlei [ 29/Sep/10 ] @Roman: The UnitOfWork (may) still be pushed as a listener into that entity, and still recieve noticies of update. Which may throw notices because the oid hashes are removed everywhere. Additionally you cant serialize the thing because you still got the UoW inside there. Comment by Jonathan H. Wage [ 04/Oct/10 ] I don't have anymore information currently. The issue was relayed to me. I will try and find some more information and report back. Comment by Benjamin Eberlei [ 03/Apr/11 ] There is no way to "fix" this issue, i am turning it into a feature request. There needs to be a "postDetach" event that is triggered where the developer can detach the change notification objects.

### [DDC-803] Create subselect queries within join statements Created: 14/Sep/10  Updated: 14/Sep/10

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: Martijn Evers Assignee: Roman S. Borschel Resolution: Unresolved Votes: 0 Labels: None

### [DDC-785] Post-Post-Persist event Created: 02/Sep/10  Updated: 14/Jan/11

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

 Type: Improvement Priority: Major Reporter: arnaud-lb Assignee: Roman S. Borschel Resolution: Unresolved Votes: 0 Labels: None

 Description
 postPersist/postUpdate events are triggered in the middle of a unitOfWork, and querying the DB in such events causes infinite loops. Doctrine attempts to flush the entity manager before running any query, which triggers flushing of entities, and postPersist/postUpdate events are triggered again. I did not checked, but the flush() before each query may be a performance problem too, if doctrine has to determine what has changed, depending on the changetracking policy. Also, it would be great if postPersist / postUpdate events were triggered after all entities have been persisted. It looks like that entities are flushed by groups of same 'type', and that events for a type are triggered once all of the elements of that group have been flushed, potentially before entities of an other type have been flushed : postPersist / postUpdate events are triggered while some other entities are still not flushed.

 Comment by Benjamin Eberlei [ 03/Sep/10 ] That is documented and for perfomance reasons we cannot move the preUpdate/postUpdate/prePersist/postPersist events to other locations inside the UnitOfWork. There is an onFlush event that allows for more flexibility and is triggered before any update/insert/delete is done by the UnitOfWork. Comment by arnaud-lb [ 04/Sep/10 ] Thanks. I understand that. Is there any chance of getting some onPostFlush or similar, which would be triggered like onFlush, but after all update/insert/delete ? Or just some post-something event which is allowed to issue db queries. Comment by Gediminas Morkevicius [ 24/Sep/10 ] onFlush you can store your entity for furher processing and on postPersist you can check if there are no more insertions and process the entity if it needs additional query I have faced all these issues and you can check http://github.com/l3pp4rd/DoctrineExtensions/tree/master/lib/DoctrineExtensions/Translatable/ for a solution to your problem Comment by Gediminas Morkevicius [ 14/Jan/11 ] I think this issue should be closed since the main reason of opening it was the possibility to execute additional queries when inserts were pending in unit of work. In current release it does not cause a flush during an additional query execution anymore.

### [DDC-779] Doctrine\ORM\Configuration should be immutable after construction of EntityManager Created: 30/Aug/10  Updated: 30/Aug/10

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

 Type: Improvement Priority: Major Reporter: Benjamin Eberlei Assignee: Roman S. Borschel Resolution: Unresolved Votes: 0 Labels: None

 Description
 Currently the Doctrine\ORM\Configuration instance is not immutable after construction of the EM, which can lead to funny behavior when changing essential dependencies such as caches or others.

### [DDC-769] Disabling discriminator column in WHERE clause Created: 26/Aug/10  Updated: 07/Sep/10

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

 Type: Improvement Priority: Major Reporter: Lars Strojny Assignee: Roman S. Borschel Resolution: Unresolved Votes: 1 Labels: None

 Description
 Per default Doctrine 2 adds an IN(...)-part to the query when hydrating an entity where a discriminator column is defined. While this makes sense as a default behavior, it would be pretty helpful if one could disable the WHERE-clause for discriminator columns alltogether for performance optimization.

 Comment by Roman S. Borschel [ 26/Aug/10 ] That would obviously produce wrong results. Maybe you can elaborate more with an example. Comment by Lars Strojny [ 07/Sep/10 ] I use ENUM("foo","bar") as discriminator columns. That means, the column will contain the right values out of the box, no further result set limiting required with WHERE.

### [DDC-1270] Incorrect QueryBuilder example Created: 11/Jul/11  Updated: 11/Jul/11

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

 Type: Documentation Priority: Major Reporter: Alex Bogomazov Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description

### [DDC-1197] Proxies should handle variable argument lists Created: 05/Jun/11  Updated: 05/Jun/11

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: Benjamin Eberlei Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description
 This is a contingency issue for https://github.com/doctrine/doctrine2/pull/60 "Fix to allow for proxy generated classes to respect methods in parent which may use func_get_args internally. Previously they would be passed nothing and thus fail. Also reduces need to build up argumentString. "

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

 Type: New Feature Priority: Major Reporter: Miha Vrhovnik Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description

 Comment by Gediminas Morkevicius [ 27/May/11 ] Sounds logic, each driver would expect NULL or data (wrapped specifically for the driver used)

### [DDC-1164] doctrine:schema:update --force == doctrine:schema:create Created: 20/May/11  Updated: 20/May/11

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: Geoff Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description
 Doctrine:schema:update --force is the same as doctrine:schema:create. Under the hood, this may not be true, but they basically accomplish the same task. Schema:create should be removed, as it is redundant. Just look at django, one command to update db: ./manage.py syncdb Not saying that django gets everything correct, but the one command to synchronize the database is consistent. doctrine:schema:update should be smart enough to do all of the work, instead of relying on the redundant doctrine:schema:create.

### [DDC-1154] Proxies should take convention while loading *ToOne associations to reduce 1 extra query Created: 17/May/11  Updated: 17/May/11

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: Guilherme Blanco Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description
 Read the IRC log: [2:38pm] guilhermeblanco: beberlei: ping [2:38pm] guilhermeblanco: I'm curious about a feature if Doctrine supports [2:38pm] guilhermeblanco: if we do this on a proxy: [2:38pm] guilhermeblanco: $proxy->getOneToOneAssoc() [2:39pm] guilhermeblanco: shouldn't Doctrine already populate the assoc entity? [2:39pm] guilhermeblanco: it would be an inner join [2:39pm] beberlei: how would doctrine know it needs it? [2:39pm] guilhermeblanco: beberlei: it always repass the ClassMetadata to Persister [2:40pm] guilhermeblanco: so all needed item is to also pass the fieldname/assocname [2:40pm] beberlei: but how would doctrine know getOneToOneASsoc() really returns this assoc [2:40pm] beberlei: it could contain any logic [2:40pm] guilhermeblanco: it wouldn't... but as soon as we trigger __load($fieldName) [2:40pm] guilhermeblanco: we know that we could populate not only the Proxy, but also assoc [2:40pm] beberlei: by convention? [2:40pm] guilhermeblanco: ya [2:41pm] beberlei: sounds good, can you open a ticket? [2:41pm] guilhermeblanco: getUser() would trigger __load('user') [2:41pm] guilhermeblanco: sure! [2:41pm] guilhermeblanco: I'll pastie this as content... it would be awesome to have [2:41pm] guilhermeblanco: I see a lot of queries here that could be optimized 

### [DDC-1144] How insert a AES_ENCRYPT value in a table field Created: 10/May/11  Updated: 10/May/11

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

 Type: New Feature Priority: Major Reporter: dquintard Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None Environment: Win XP, MySql5, Php5.3, ZendFramework 1.11.4

 Description

### [DDC-1016] Example code does not reflect real code Created: 03/Feb/11  Updated: 03/Feb/11

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

 Type: Documentation Priority: Major Reporter: thoth Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None Environment: Website

 Description
 http://www.doctrine-project.org/docs/orm/2.0/en/reference/working-with-objects.html#entity-state In the switch cases all the UnitOfWork constants are invalid. Example: UnitOfWork::NEW instead of being UnitOfWork::STATE_NEW

### [DDC-1011] Finding out if a model is persist Created: 02/Feb/11  Updated: 02/Feb/11

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

 Type: Documentation Priority: Major Reporter: Ronny Deter Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description
 To find out if a model is persist, is missing in the documentation of doctrine 2. To become the state of an model you must call the entitymanager->getUnitOfWork()->getEntityState(model)

### [DDC-998] Code example for custom AST functions incorrect Created: 23/Jan/11  Updated: 23/Jan/11

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

 Type: Documentation Priority: Major Reporter: Timo A. Hummel Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description
 On http://www.doctrine-project.org/docs/orm/2.0/en/reference/dql-doctrine-query-language.html#adding-your-own-functions-to-the-dql-language the code example is slightly incorrect. Mistakes: Lexer::T_ABS doesn't exist anymore, I assume Lexer::T_IDENTIFIER is what one wants to use Missing use for \Doctrine\ORM\Query\Lexer Additionally, the section should tell the user that he best has a look at lib/Doctrine/ORM/Query/AST/Functions/* to learn how to write custom functions. It also could be noted that stored procedures can be called with custom functions.

### [DDC-999] DQL always needs a FROM clause, should be changed Created: 23/Jan/11  Updated: 23/Jan/11

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

 Type: New Feature Priority: Major Reporter: Timo A. Hummel Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 1 Labels: None

 Description
 Sometimes a developer needs to issue a query without a FROM clause. This especially occurs using the QueryBuilder, when you may or may not have a table to select from, but call a stored procedure always. Example: $query =$em>createQuery('SELECT (1+1)');  The above query fails because the lexer expects T_FROM. If you replace (1+1) with a stored procedure, this example makes more sense. One might argue about that you should use DBAL directly, but I disagree, because it always can happen that you end up in a situation like this: $qb =$em->createQueryBuilder(); $qb->select("SOMEFANCYPROCEDURE()"); if ($condition) { $qb =$qb->from("additionalTable t"); } 

### [DDC-993] Cookbook: Overriding the ID Generator during a database migration Created: 19/Jan/11  Updated: 28/Oct/12

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

 Type: Documentation Priority: Major Reporter: Timo A. Hummel Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 1 Labels: None

 Description
 If you need to override the ID Generator, e.g. during a migration, you can do that in your migration script as follows: Overriding the ID generator $em->getClassMetadata('foo\bar\Entity')->setIdGenerator(new \Doctrine\ORM\Id\AssignedGenerator());$em->getClassMetadata('foo\bar\Entity')->setIdGeneratorType(constant('Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE')); Make sure that both calls equal to the same generator type. You can now modify the @Id fields in your entities. Additionally, make sure that you set the IdGenerator after you created the database using e.g. SchemaTool->create().

 Comment by Endre Kósa [ 27/Oct/12 ] Hi, this doesn't seem to work for me. I have written a small database export / import utility. As long as I use the automatic ID generation, everything works flawlessly, but I'm trying to preserve the existing IDs. I do exactly what you've suggested in your post. It works for @OneToOne relations, but I get the following error messages when persisting entities that are parts of @ManyToOne relations: Notice: Undefined index: [....] in [...]Doctrine/ORM/UnitOfWork.php on line 2655 I'm using version 2.2.2 Am I doing something wrong? Comment by Endre Kósa [ 28/Oct/12 ] Never mind. I've upgraded to Doctrine 2.3.0 and it works as expected.

### [DDC-947] Optmize Code-Generation Strategies Created: 24/Dec/10  Updated: 29/Mar/11

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

 Type: Improvement Priority: Major Reporter: Benjamin Eberlei Assignee: Jonathan H. Wage Resolution: Unresolved Votes: 0 Labels: None

 Description
 We should optimize code-generation somehow.

 Comment by Benjamin Eberlei [ 29/Mar/11 ] Descheduled to 2.x

### [DDC-946] Evaluate optional use of igbinary for serialization Created: 22/Dec/10  Updated: 22/Dec/10

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: Benjamin Eberlei Assignee: Roman S. Borschel Resolution: Unresolved Votes: 1 Labels: None

 Description
 Igbinary is supposed to be faster and better than serialize/unserialize(). We should check if its relevant for us (metadata and query caching for example): https://github.com/phadej/igbinary

 Comment by Benjamin Eberlei [ 22/Dec/10 ] http://ilia.ws/archives/211-Igbinary,-The-great-serializer.html#extended

### [DDC-930] A table cannot have more than one many to many relationship with the same table when using reverse engineer Created: 13/Dec/10  Updated: 13/Dec/10

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

 Type: Improvement Priority: Major Reporter: Jiri Helmich Assignee: Roman S. Borschel Resolution: Unresolved Votes: 0 Labels: None Environment: FreeBSD, PostgreSQL 8.4

 Description
 This is caused by taking the join column name as the identifier while generating a property name for annotation. The mapping driver detects that the same property is already defined and ends the convert process. A little bit smarter approach for me was to take the local table name. But this assumes a specific style of join table naming convention. Doctrine\ORM\Mapping\Driver\DatabaseDriver::loadMetadataForClass() Replace: $associationMapping['fieldName'] = Inflector::camelize(str_replace('_id', '', strtolower(current($otherFk->getColumns())))); With: $name = explode("_",$myFk->getLocalTableName()); if (count($name) > 1) { array_shift($name); } $name = implode("_",$name); $associationMapping['fieldName'] = Inflector::camelize(str_replace('_id', '', strtolower($name))); Maybe to switch to this behavior with an additional option?

### [DDC-923] Add note about DateTime Query Parameter Type Hint Created: 10/Dec/10  Updated: 10/Dec/10

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

 Type: Documentation Priority: Major Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

### [DDC-919] subselect Created: 08/Dec/10  Updated: 20/Mar/11

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

 Type: Documentation Priority: Major Reporter: Mungiu Dragos Assignee: Roman S. Borschel Resolution: Unresolved Votes: 0 Labels: None

 Description
 i'd like to see more example in documentation with this subselects [23:08] can you open a tciket on jira? then i dont forget to do that when i have time

 Comment by Alberto [ 20/Mar/11 ] Subselect as columns or FROM clause should have mor examples.

### [DDC-896] Use PDepend for Code-Generation Created: 27/Nov/10  Updated: 27/Nov/10

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

 Type: Improvement Priority: Major Reporter: Benjamin Eberlei Assignee: Jonathan H. Wage Resolution: Unresolved Votes: 0 Labels: None

 Description
 Our current code-generation tool has many shortcomings and due to its hard to test nature also many (known and unknown) bugs, as well as high maintenance. Since people are overusing this tool and I am sort of annoyed by how much time goes into this we should rewrite this in a two-step procedure: 1. Move code into Common so we can share it between ORM, Mongo and CouchDB. 2. Use PDepend to read an entities source file (it generates an AST) and modify the AST with the required changes. This gives us the advantage of having to maintaining less code for this stuff.

### [DDC-1475] Documentation for One-To-Many, Bidirectional Association does not have YAML example Created: 07/Nov/11  Updated: 07/Nov/11

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

 Type: Documentation Priority: Major Reporter: Christian Stoller Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description
 When you are looking for a config example for the bidirectional mapping of an one-to-many association you will just find an example with XML, but not with YAML or PHP. It would be nice if somebody could add an example or a link to the bidirectional one-to-one association, because it should be the same, right? Here the link to the example: http://www.doctrine-project.org/docs/orm/2.0/en/reference/association-mapping.html#one-to-many-bidirectional

### [DDC-1465] Fetching partial objects doesn't work if HINT_FORCE_PARTIAL_LOAD is not explicitly used Created: 02/Nov/11  Updated: 11/Nov/11

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

 Type: Bug Priority: Major Reporter: Julien Pauli Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 1 Labels: None

 Duplicate duplicates DDC-624 Partial object query that leaves out ... Open

 Description
 Using the DQL "partial" keyword is not enough to get a partial entity as a result. The DQL hint HINT_FORCE_PARTIAL_LOAD must be used as well. $q =$em->createQuery('SELECT partial r.{id,comment} FROM Entities\Rating r WHERE r.id=3'); $r =$q->getResult() /* HYDRATE_OBJECT is the default hydration mode */  Here, $r contains the full Entity, a SELECT * has been sent $q = $em->createQuery('SELECT partial r.{id,comment} FROM Entities\Rating r WHERE r.id=3');$q->setHint(Doctrine\ORM\Query::HINT_FORCE_PARTIAL_LOAD, 1); $r =$q->getResult() /* HYDRATE_OBJECT is the default hydration mode */  Here, $r contains only the selected fields, hence a true partial Entity ### [DDC-1459] Move DDC-331, DDC-448, DDC-493, DDC-513, DDC-698 Tests into SQLGeneration Testsuite Created: 29/Oct/11 Updated: 01/Aug/12 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: Benjamin Eberlei Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None ### [DDC-1450] UnitOfWork Transaction Rollback Support Created: 24/Oct/11 Updated: 20/Dec/11 Status: Open Project: Doctrine 2 - ORM Component/s: ORM Affects Version/s: None Fix Version/s: 2.x Security Level: All  Type: Improvement Priority: Major Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None  Description  The UnitOfWork does not handle the case very well where a rollback is necessary. Can this be optimized?  Comments  Comment by Guilherme Blanco [ 20/Dec/11 ] Updating fix version ### [DDC-1443] Subscribers reachs maximum nesting level when creating association on pre/postPersist with cascade persist Created: 20/Oct/11 Updated: 29/Oct/11 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: Guilherme Blanco Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None  Attachments: DDC1443Test.php DDC1443Test.php  Description  Suppose a situation where: A -> B Where the OneToOne unidirectional association contains cascade persist. If I decide to save an entity B that should create an A instance, it goes into maximum nesting level no matter if I track prePersist or postPersist.  Comments  Comment by Guilherme Blanco [ 20/Oct/11 ] Failing test case Comment by Guilherme Blanco [ 20/Oct/11 ] Uploading a new version, now passing successfully, but consuming the onFlush event (which should not be ideal). Comment by Benjamin Eberlei [ 29/Oct/11 ] Ah yes, this never worked. The transaction stuff will fix that. You have to use scheduleForInsert() something inside prePersist. ### [DDC-1445] Improve error messages Created: 22/Oct/11 Updated: 20/Dec/11 Status: Open Project: Doctrine 2 - ORM Component/s: None Affects Version/s: None Fix Version/s: 2.x Security Level: All  Type: Improvement Priority: Major Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None  Description  Error messages throughout ClassMetadata validation and UnitOfWork cycles can be significantly improved. Work is being done on: https://github.com/doctrine/doctrine2/tree/ImproveErrorMessages  Comments  Comment by Guilherme Blanco [ 20/Dec/11 ] Updating fix version ### [DDC-1441] Metadata cannot be loaded for not registered proxy objects Created: 20/Oct/11 Updated: 05/Apr/12 Status: Open Project: Doctrine 2 - ORM Component/s: ORM Affects Version/s: 2.1.2 Fix Version/s: None Security Level: All  Type: Improvement Priority: Major Reporter: Aigars Gedroics Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None Environment: MySQL, Ubuntu, PHP 5.3.6  Attachments: DDC1441Test.php not-loaded-proxy-patch.diff  Description  We are using several Doctrine managers in our project with the same entity classes and different database tables. The problem appears when we are willing to merge entity with lazy associations from one manager to another. The second entity manager instance hasn't got the proxy object metadata defined yet so it fails with Doctrine\ORM\Mapping\MappingException exception "Class EntityProxy is not a valid entity or mapped super class.". If both entity managers share the proxy objects the problem can be fixed by calling $em->getProxyFactory()->getProxy('Entity', -1);  which will register the entity metadata for the proxy classname as well. Still if the proxy configuration differs, there is no fix found without changing the Doctrine ORM code. The fix inside the Doctrine would be to detect Proxy classes before loading the metadata and load the metadata for it's parent class instead. Please see the diff attached with proposed solution. Also I think this issue could arise when unserialized entity objects will be merged into the entity manager. I will try creating test case for this.

 Comment by Aigars Gedroics [ 24/Nov/11 ] Test case attached. Comment by Aigars Gedroics [ 05/Apr/12 ] See my pull request in https://github.com/doctrine/doctrine2/pull/332.

### [DDC-1438] Add test for DDC-1437 Created: 19/Oct/11  Updated: 19/Oct/11

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: Benjamin Eberlei Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description

### [DDC-1429] Add a method to the unit of work that merges any detached entity into UoW without calling SQL Created: 17/Oct/11  Updated: 17/Oct/11

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: Benjamin Eberlei Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description
 This is for those that know what they are doing

### [DDC-1393] Skipping tables or columns in database driver or SchemaTool Created: 24/Sep/11  Updated: 20/Dec/11

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

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

 Description
 There should be a sane way to skip sources of errors in SchemaTool and the DatabaseDriver.

 Comment by Benjamin Eberlei [ 24/Sep/11 ] Idea: Develop a datastructure of sorts that allows saving information about skipping tables and columns therein when reverse engeneering. Comment by Guilherme Blanco [ 09/Dec/11 ] This is not possible unless you take advantage of Topological Sorting to map class dependencies like we do inside of UnitOfWork AFTER creating the ClassMetadata. The necessity of having this is mandatory because we can never skip classes that have associations to other ones though FK. You may try that, but it doesn't compensate the effort. I'd rather mark this bug as won't fix, but I'm leaving for you do that. =) Comment by Guilherme Blanco [ 20/Dec/11 ] Updating fix version

### [DDC-1380] Standardize proxy class naming Created: 18/Sep/11  Updated: 18/Sep/11

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

 Type: Improvement Priority: Major Reporter: Johannes Schmitt Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description

### [DDC-1371] Optimistic Locking using hash column or all columns Created: 10/Sep/11  Updated: 10/Sep/11

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: Benjamin Eberlei Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description
 We can implement optimistic locking using hash values or other all columns of an entity

### [DDC-1357] Queries with multiple joins resulting in multiple scalar results for each top level entity only retain one scalar value for each entity Created: 01/Sep/11  Updated: 01/Sep/11

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: Nils Adermann Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description
 Consider this example: select g.id, u.id, u.status, count(p.phonenumber) numPhones from Group * g join g.user u join u.phonenumbers p group by g.id, u.status, u.id With data: phonenumbers: [1, 2, 3, 4, 5, 6] users: [{id: 1, status: developer, phonenumbers: [1, 2]}, {id: 2, status: developer, phonenumbers: [3]}, {id: 3, status: developer, phonenumbers: [4, 5, 6]}] groups: [{id: 1, users: [1, 2]]}, {id:2, users: [3]}]  The result currently is: array( array( 0 => object(CmsGroup) { 'id' => 1, 'users' => Collection( object(CmsUser) { 'id' => 1 }, object(CmsUser) { 'id' => 2 } ) }, 'numPhones' => 1 ), array( 0 => object(CmsGroup) { 'id' => 2, 'users' => Collection( object(CmsUser) { 'id' => 3 } ) }, 'numPhones' => 3 ) )  Note that the first entry contains only one value numPhones => 1, even though there are two users associated with that group. One of whom has 2 phone numbers and the other has 1. The result I would expect is: array( array( 0 => object(CmsGroup) { 'id' => 1, 'users' => Collection( object(CmsUser) { 'id' => 1 }, object(CmsUser) { 'id' => 2 } ) }, 'numPhones' => array(2, 1) ), array( 0 => object(CmsGroup) { 'id' => 2, 'users' => Collection( object(CmsUser) { 'id' => 3 } ) }, 'numPhones' => array(3) ) )  The difference is that numPhones for each row now contains an array of the scalar values matching the corresponding users.

 Comment by Nils Adermann [ 01/Sep/11 ] You can find a test case for the correct result here: https://github.com/naderman/doctrine2/commit/a1ca3d9847cbc514fc951fb0b221b26fe03a6619

### [DDC-1347] Github-PR-110 by shesek: Support NULL in EntityRepository's magic findBy and findOneBy methods Created: 25/Aug/11  Updated: 25/Aug/11

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: Benjamin Eberlei Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description
 This issue is created automatically through a Github pull request on behalf of {username} : Message: The magic findBy and findOneBy methods don't support passing NULL as the value, because ["we cannot (yet) transform it into IS NULL"](https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/EntityRepository.php#L207). However, BasicEntityPersister::_getSelectConditionSQL() [does support that](https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php#L1229). It seems like leftovers from when there was no support for it. I tried it locally (after applying this change) and it does seem to work well.

### [DDC-1342] Github-PR-109: Remove trailing spaces Created: 21/Aug/11  Updated: 21/Aug/11

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: Benjamin Eberlei Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description
 alOneh created a pull request on Github:

### [DDC-1320] Ship Immutable date time with Doctrine Common, use in ORM - Should implement __toString() Created: 06/Aug/11  Updated: 31/Oct/11

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

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

 Dependency depends on DDC-1316 Insert statement for joined subclass ... Resolved

 Comment by Benjamin Eberlei [ 31/Oct/11 ] Has to be pushed back as immutable date time cannot be implemented in userland that well.

### [DDC-1308] Add cache for transient information and invalidation for ClassMetadata Created: 31/Jul/11  Updated: 20/Dec/11

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

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

 Description
 Two different things have to be improved in the caching: 1. The information isTransient() has to be moved to the ClassMetadataFactory and cached there. 2. The information getAllClassMetadataNames() can be cached 3. A debug/development mode should be introduced, leading to filemtime caching and checks so that you can use ApcCache and such in development.

 Comment by Guilherme Blanco [ 20/Dec/11 ] Updating fix version

### [DDC-2128] [GH-507] Now MetaDataFilter takess also regexp. For example whern you want to Created: 06/Nov/12  Updated: 06/Jan/13

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: Benjamin Eberlei Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description

### [DDC-2102] Make optional SubselectFromClause Created: 25/Oct/12  Updated: 25/Oct/12

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: Martin Hasoň Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description
 Subselect ::= SimpleSelectClause [SubselectFromClause] [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]

### [DDC-2100] Getting Started: Code First PHP fatal error:Call to undefined method Bug::setDescription() Created: 24/Oct/12  Updated: 24/Oct/12

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

 Type: Documentation Priority: Major Reporter: bronze1man Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None Environment: ubuntu 1204 php5.3.8

 Description

### [DDC-2043] Extra cache operation in DBAL\Cache\ResultCacheStatement.php Created: 26/Sep/12  Updated: 26/Sep/12

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

 Type: Improvement Priority: Major Reporter: Bogdan Albei Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None Environment: CentOS, PHP 5.3.10

 Description
 This is the closeCursor() method in DBAL\Cache\ResultCacheStatement.php: public function closeCursor() { $this->statement->closeCursor(); if ($this->emptied && $this->data !== null) {$data = $this->resultCache->fetch($this->cacheKey); if ( ! $data) {$data = array(); } $data[$this->realKey] = $this->data;$this->resultCache->save($this->cacheKey,$data, $this->lifetime); unset($this->data); } }  We are using Memcache and I noticed an extra GET operation on all cache misses. In the code above I believe the fetch call is not necessary and that the code would do the same without it. Also, may I ask why is the SQL used as a key in the cached data?

 Comment by Christophe Coevoet [ 26/Sep/12 ] The SQL is used as a key because it is what identifies the query which is done (well, the statement and the parameters) Comment by Bogdan Albei [ 26/Sep/12 ] The cacheKey already identifies the query(or at least it should). Would we have cases where different queries would want to use the same cache key?

### [DDC-2021] Array Data in Member OF Created: 09/Sep/12  Updated: 09/Sep/12

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

 Type: New Feature Priority: Major Reporter: vahid sohrabloo Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: array, dql

 Description
 Hi. First sorry for my bad english. In SELECT u.id FROM CmsUser u WHERE :groupId MEMBER OF u.groups DQL we can't use Array of groupId like

### [DDC-1999] Lazy loading doesn't get the field type when generating sql Created: 29/Aug/12  Updated: 29/Aug/12

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: victor Velkov Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description
 When calling with lazy loading the Sql generated doesn't convert the parameters according to their types. After debugging the problem I found that the problem is in the getType($field,$value) function in the BasicEntityPersister as it is it will never be able to return the filed type when called for lazy loading for oneToMany or ManyToMany. I put a quick fix for my self  private function getType($field,$value) { switch (true) { //here we have original code default: $type = null; // my fix starts here$fieldParts = explode('.', $field); if (count($fieldParts > 1)) { foreach ($this->_class->associationMappings as$mapping) { if (isset($mapping['joinColumnFieldNames'][$fieldParts[1]])) { $targetClass =$this->_em->getClassMetadata($mapping['targetEntity']); if (isset($targetClass->fieldNames[$fieldParts[1]])) {$type = $targetClass->fieldMappings[$targetClass->fieldNames[$fieldParts[1]]]['type']; } break; } } } //my fix end here } //here we have original code return$type; }  i have only added that check in the default case of the switch. I am not sure if that is the most elegant way. I hope that helps and that it will be fixed soon. Thanks for the great work .

 Comment by Benjamin Eberlei [ 29/Aug/12 ] Fabio B. Silva Guilherme Blanco do we have a current best practice/policy regarding casting of join column types? There are some issues regarding it, this is another one. Comment by Guilherme Blanco [ 29/Aug/12 ] We avoid the manual breakdown of path expressions. Also, in BasicEntityPersister it is done behind the scenes and can get into weird scenarios. Personally speaking, I don't see how we can easily fix this issue.

### [DDC-1991] Add parameter indexBy to EntityRepository->createQueryBuilder() Created: 20/Aug/12  Updated: 20/Aug/12

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: Philipp Cordes Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description
 createQueryBuilder() currently doesn’t have a parameter to set the third option on the FROM fragment: indexBy. Right now you have to read it, create a new From with the read properties and your desired indexBy value and replace the existing one on the QueryBuilder. Should be ten minutes’ work including tests. Thanks a lot!

### [DDC-1965] Multiple Index fails if index name not specified Created: 02/Aug/12  Updated: 02/Aug/12

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

 Type: Bug Priority: Major Reporter: Pont Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: Cli Environment: Ubuntu 11.04, PHP 5.3.6 with Suhosin-patch, Symfony 2.0.15

 Description
 @ORM\Table(name="applications", indexes={@ORM\Index(name="csl_idx", columns= {"createdAt", "status", "loanType"}), @ORM\Index(name="s_idx", columns={"status"}), @ORM\Index(name="l_idx", columns={"loanType"})}) the above Annotation creates 3 different indexes BUT when: * @ORM\Table(name="applications", indexes={@ORM\Index(columns={"createdAt", "status", "loanType"} ), @ORM\Index(columns= {"status"} ), @ORM\Index(columns= {"loanType"} )}) index-names not specified Symfony2 schemaUpdate tools shows only the last Index

### [DDC-1963] Remove by-ref access to changeset in lifecycle event args Created: 31/Jul/12  Updated: 31/Jul/12

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

 Type: Improvement Priority: Major Reporter: Marco Pivetta Assignee: Marco Pivetta Resolution: Unresolved Votes: 0 Labels: None

 Description
 UoW currently passes computed changesets to lifecycle event args byref. This has to be changed to force users to use UoW public API to modify changesets instead.

### [DDC-1960] mapping joins in native queries breaks if select columns are starting with columns from joined table Created: 31/Jul/12  Updated: 21/Nov/12

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

 Type: Bug Priority: Major Reporter: Thomas Subera Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None Environment: ubuntu kernel 2.6.32-40-server php 5.3.10-1ubuntu2ppa6~lucid with Suhosin-Patch (cli) apache 2 2.2.14-5ubuntu8.9 postgres 9.1.4-1~lucid4

 Attachments: testcase.zip

 Description

### [DDC-1570] GH-243: Add ProxyFactoryInterface to allow custom proxy factories Created: 28/Dec/11  Updated: 28/Dec/11

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: Benjamin Eberlei Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description
 Pull-Request was automatically synchronized: https://github.com/doctrine/doctrine2/pull/243 I'd love to have my custom proxy factory used with ORM, which is not possible at the moment (my experimental proxy https://github.com/juzna/doctrine2/commit/7822446036201b066e390b2e182cac1dc0c85430 and some comments about it http://blog.juzna.cz/2011/06/lazy-loading-in-php/)

### [DDC-1564] MySQL Failure when using setFirstResult() and omitting setMaxResults() Created: 25/Dec/11  Updated: 28/Dec/11

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

 Type: Improvement Priority: Major Reporter: Timo A. Hummel Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description
 When using setFirstResult() and omitting setMaxResults(), MySQL throws an error. This was very confusing for me until I dumped the SQL statements and found out the reason. I know that MySQL doesn't directly support this, their manual says that you should set the second parameter to LIMIT to a very high number (18446744073709551615 in their example). I'd recommend that either throwing an error in the specific platform driver or follow the MySQL example.

 Comment by Benjamin Eberlei [ 28/Dec/11 ] Changed into improvement, i am not sure how this relates to other databases. You can just use this workaround yourself so long.

### [DDC-1553] JTI Joining root tables could include ON ... AND root.id IS NOT NULL for each root in the inheritance Created: 22/Dec/11  Updated: 22/Dec/11

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: Alexander Assignee: Alexander Resolution: Unresolved Votes: 0 Labels: None

 Description
 Would lead to more optimal queries, while still allowing for LEFT JOIN. Also related to this: https://groups.google.com/forum/#!topic/doctrine-user/znkkP7IF_Aw

 Comment by Alexander [ 22/Dec/11 ] Again I can pick this up if this improvement is agreed upon.

### [DDC-1549] GH-232: Recursive check for entity identifiers and hashes Created: 20/Dec/11  Updated: 22/Mar/12

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: Benjamin Eberlei Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description
 Pull-Request was automatically synchronized: https://github.com/doctrine/doctrine2/pull/232 Hi all! This PR will add a better support for entities with association keys. getType will check recursively to find a type for the identifier. getIndividualValue will search recursively to find the identifier value trygetById improved, using a recursive function to find an id value instead of implode functions (that cause exceptions if the identifier is an object and do not implements __toString method).

 Comment by Benjamin Eberlei [ 28/Dec/11 ] Mark as improvement Comment by Benjamin Eberlei [ 22/Mar/12 ] A related Github Pull-Request [GH-232] was https://github.com/doctrine/doctrine2/pull/232

### [DDC-1552] JTI Owning table for identifier columns could/should be the entitytable Created: 22/Dec/11  Updated: 22/Dec/11

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: Alexander Assignee: Alexander Resolution: Unresolved Votes: 0 Labels: None

 Description
 When ordering a JTI entity on id, the generated SQL will use the table of the root entity. This is because the root entity is listed as owner of the field in the _owningTableMap, leading to non-optimal queries. More information see: https://groups.google.com/forum/#!topic/doctrine-user/znkkP7IF_Aw

 Comment by Alexander [ 22/Dec/11 ] I can pick this up if it's agreed upon that this could indeed be improved. Comment by Marco Pivetta [ 22/Dec/11 ] The problem here is that joining with a JTI causes LEFT JOINS, which don't perform very well when it comes to sorting the results. Just as a quick reference, here's where "something" should be changed to get this working: https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Query/SqlWalker.php#L316 When the field is part of the primary key, the field used for sorting results should be the one of the table of the entity itself, and not of the root of the CTI.

### [DDC-1543] Support for Mapping Files on Traits Created: 17/Dec/11  Updated: 17/Dec/11

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

 Type: New Feature Priority: Major Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description
 With PHP 5.4 and traits coming we should find a way where you can add xml and yml configurations for a trait and upon loading an entity X, it also loads the trait configuration of this entity.

### [DDC-1538] GH-217: [BUG] Schema Manager had no way to define extra options Created: 14/Dec/11  Updated: 17/Dec/11

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: Benjamin Eberlei Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description
 Pull-Request was automatically synchronized: https://github.com/doctrine/doctrine2/pull/217 Schema Manager had no way to define extra options ("comment" option for example). It is possible to add these options via Annotations. After the fix adding @ORM\Column(type="string", options= {"comment" = "test"} ) starts to work producing valid SQL schema with COMMENT output.

### [DDC-1530] HIDDEN values cannot be used in WhereClause Created: 12/Dec/11  Updated: 25/Jan/12

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

 Type: Improvement Priority: Major Reporter: Guilherme Blanco Assignee: Guilherme Blanco Resolution: Unresolved Votes: 0 Labels: None

 Description
 SELECT u, u.name AS HIDDEN n FROM User u WHERE n = ?1  Is broken. Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'sclr16' in 'where clause  On a query like: SELECT s0_.id AS id0, s0_.a AS a1, s0_.b AS b2, s0_.c AS c3, s0_.d AS d4, s0_.e AS e5, s0_.f AS f6, s0_.g AS g7, s0_.h AS h8, s0_.i AS i9, s0_.j AS j10, s0_.k AS k11, s0_.l AS l12, s0_.m AS m13, s0_.n AS n14, s0_.o AS o15, 123456789 AS sclr16, s0_.p AS p17 FROM myEntity s0_ WHERE s0_.a = 1 AND sclr16 <= ? ORDER BY sclr16 ASC 

### [DDC-1785] Paginator problem with SQL Server around DISTINCT keyword. Created: 18/Apr/12  Updated: 19/Jan/13

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

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

 Description
 PDOException: SQLSTATE[42000]: [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near the keyword 'DISTINCT'. (uncaught exception)

 Comment by Craig Mason [ 18/Oct/12 ] There are four major issues with this: 1: SQLServerPlatform.php modifies the query to prepend 'SELECT ROW_NUMBER() OVER ($over)', which is inserted before the DISTINCT keyword. 2: The order needs to be placed inside the OVER($over) block. At this point, the regex is using the exact column name rather than the alias, so the outer query cannot ORDER. 3: The DISTINCT queries select only the ID columns - as OVER() required the sort column to be available in the outer query, IDs alone will not work. 4: SQL Server cannot DISTINCT on TEXT columns. 2005,2008 and 2012 recommend using VARCHAR(MAX) instead, which does support it. That doesn't help us with 2003. We work around that with a custom TEXT type that casts as varchar. Incidentally, 2012 supports LIMIT, which gets rid of this issue altogether. Edit: Added #3 Comment by Craig Mason [ 18/Oct/12 ] I have a (very hacky) implementation working that uses regexes to correct the query so that it will execute. This also required modification in the ORM paginator, to select all columns instead of just IDs. This is certainly not a patch - more guidance. One interesting point... I had to wrap the whole query in a second SELECT *, as the WHERE IN confusingly returns non-distinct rows when part of the first inner query. No idea why this happens, but moving it out one layer makes it operate correctly. Comment by Craig Mason [ 25/Oct/12 ] Updated, view all commits for this experimental branch here: https://github.com/CraigMason/dbal/commits/mssql-distinct Comment by Craig Mason [ 29/Oct/12 ] This got waaaay too messy with regex alone due to the complicated nesting. As such, I have written the basis of a new SqlWalker class which can be used to create DISTINCT queries based on the root identifiers. It's not proper DISTINCT support, but it's a step forward. https://github.com/CraigMason/DoctrineSqlServerExtensions I've also added a Paginator (which was the original issue I had!) The current SqlWalker always sticks the ORDER BY on the end of the query, which just doesn't work properly with SqlServer. Is a vendor-specific walker breaking the DQL abstraction? Should this type of code be on the Platform object in the DBAL? Anyway, this repo fixes our immediate problem, and it would be good to revisit this in a wider context. Hopefully we can get some good SQL server support - there are plenty of other issues to deal with (UTF-8/UCS2, nvarchar etc) Comment by Benjamin Eberlei [ 19/Jan/13 ] Craig Mason We don't have an SQL Server expert on the team, so if you want really good support you should join and help us with it.

### [DDC-1760] [GH-324] simplified __call method Created: 03/Apr/12  Updated: 07/Apr/12

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: Benjamin Eberlei Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description
 This issue is created automatically through a Github pull request on behalf of brikou: Message:

 Comment by Benjamin Eberlei [ 04/Apr/12 ] A related Github Pull-Request [GH-324] was synchronize https://github.com/doctrine/doctrine2/pull/324 Comment by Benjamin Eberlei [ 06/Apr/12 ] A related Github Pull-Request [GH-324] was synchronize https://github.com/doctrine/doctrine2/pull/324 Comment by Benjamin Eberlei [ 07/Apr/12 ] A related Github Pull-Request [GH-324] was synchronize https://github.com/doctrine/doctrine2/pull/324

### [DDC-1756] Allow for master table only models on joined subclass inheritance Created: 03/Apr/12  Updated: 03/Apr/12

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: Markus Wößner Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description

### [DDC-1750] [GH-319] [WIP] Added support to Multiple ID Generators Created: 01/Apr/12  Updated: 27/May/12

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: Benjamin Eberlei Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

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

 Comment by Benjamin Eberlei [ 01/Apr/12 ] A related Github Pull-Request [GH-319] was synchronize https://github.com/doctrine/doctrine2/pull/319 Comment by Benjamin Eberlei [ 01/Apr/12 ] A related Github Pull-Request [GH-319] was synchronize https://github.com/doctrine/doctrine2/pull/319 Comment by Benjamin Eberlei [ 02/Apr/12 ] A related Github Pull-Request [GH-319] was synchronize https://github.com/doctrine/doctrine2/pull/319 Comment by Benjamin Eberlei [ 02/Apr/12 ] A related Github Pull-Request [GH-319] was synchronize https://github.com/doctrine/doctrine2/pull/319 Comment by Benjamin Eberlei [ 03/Apr/12 ] A related Github Pull-Request [GH-319] was synchronize https://github.com/doctrine/doctrine2/pull/319 Comment by Benjamin Eberlei [ 03/Apr/12 ] A related Github Pull-Request [GH-319] was synchronize https://github.com/doctrine/doctrine2/pull/319 Comment by Benjamin Eberlei [ 04/Apr/12 ] A related Github Pull-Request [GH-319] was synchronize https://github.com/doctrine/doctrine2/pull/319 Comment by Benjamin Eberlei [ 06/Apr/12 ] A related Github Pull-Request [GH-319] was synchronize https://github.com/doctrine/doctrine2/pull/319 Comment by Benjamin Eberlei [ 07/Apr/12 ] A related Github Pull-Request [GH-319] was synchronize https://github.com/doctrine/doctrine2/pull/319

### [DDC-2275] [GH-568] Fixed plural variable names to singular when generating add or remove methods for entities Created: 04/Feb/13  Updated: 04/Feb/13

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

 Description
 This issue is created automatically through a Github pull request on behalf of alexcarol: Message: Changed generateEntityStubMethod so that variable names in add or remove methods are singular too Edited tests for EntityGenerator so that variable names are checked too

### [DDC-2239] Allow dynamic modification of select queries (either filter the AST or query) Created: 11/Jan/13  Updated: 11/Jan/13

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: Nathanael Noblet Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description
 I had built and used the following for doctrine 1: http://web.archive.org/web/20110705035547/http://www.doctrine-project.org/projects/orm/1.2/docs/cookbook/record-based-retrieval-security-template/en#record-based-retrieval-security-template I'd like to build something similar for D2 based projects. ocramius in IRC suggested a bug report/Improvement request. Figured that perhaps a custom event "dql_parse" or "ast_render" passing the AST or Query as a parameter. I'm under a tight timeline and am willing to pay for aid/feature implementation.

### [DDC-2223] unable to use scalar function when a scalar expression is expected Created: 04/Jan/13  Updated: 04/Jan/13

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

 Type: Bug Priority: Major Reporter: Alexis Lameire Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: dql Environment: (not affected by this bug)

 Description
 the DQL Parser don't parse properly functions when a ScalarExpression is needed like of all case functions. In fact first function token is interpreted as a T_IDENTIFIER and enter on line 1663 of Doctrine\ORM\Query\Parser class. in search of math operator, when not found this case considere that the token is a row element with no considération of the functions procession treated after. fix of this bug consist to enclose the line 1672 by a if (!$this->_isFunction()). ### [DDC-2219] computeChangeSets array_merging for associationMappings problem ? Created: 02/Jan/13 Updated: 07/Jan/13 Status: Open Project: Doctrine 2 - ORM Component/s: None Affects Version/s: None Fix Version/s: None Security Level: All  Type: Documentation Priority: Major Reporter: yohann.poli Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: unitofwork  Description  Is this normal that when i call "$changeset = $unitOfWork->getEntityChangeSet($myObject);", it only return changes of root Object, all changes in sub collection (OneToMany) are less (not merging in the changeset) ? Is there an issue for that?

 Comment by Marco Pivetta [ 02/Jan/13 ] Changesets of collections are computed separately from those of entities. Comment by yohann.poli [ 02/Jan/13 ] Have to call the compute method for each collection of the entity ? Comment by Benjamin Eberlei [ 06/Jan/13 ] Yes you have to, but this kind of operation seems weird. What are you trying to achieve. Comment by yohann.poli [ 07/Jan/13 ] I manage a complex entity who have a collection entity (each entity in this collection have another collection entity) attributes and i need to now if the flush method has "really" execute an update. For example if the level 3 entity is update, i have to know in the root entity all changes apply in child...

### [DDC-2185] Better explain DQL "WITH" and implications for the collection filtering API Created: 04/Dec/12  Updated: 17/Dec/12

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

 Type: Documentation Priority: Major Reporter: Matthias Pigulla Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: collection, documentation, dql, filtering

 Description
 Available documentation is a bit thin regarding the "WITH" clause on JOIN expressions. Only a single example is provided in http://docs.doctrine-project.org/en/2.1/reference/dql-doctrine-query-language.html#dql-select-examples WITH seems to allow to only "partially" load a collection, so the collection in memory does not fully represent the associations available in the database. The resulting collection is marked as "initialized" and it seems there is no way to tell later on whether/how (with which expression) the collection has been initialized. When using the collection filtering API, the "initialized" flag on the collection will lead to in-memory processing. If a collection has been loaded WITH a restricting clause and another filter is applied later, results may not be what one might expect. I assume this is by design (no idea how the collection could be "partially" loaded and behave correctly under all conditions), so filing it as a documentation issue.

 Comment by Matthias Pigulla [ 17/Dec/12 ] An additional observation: If you eager-load a collection using WITH, for the resulting entities that collection is marked as initialized as described above. Should you happen to come across the same entity during hydration in another (later) context where you explicitly eager load the same association without the WITH restriction (or with another one), the collection on that (existing) entity won't be re-initialized and still contains the associated objects found during the first query.

### [DDC-2170] Decorator base classes for query related objects Created: 26/Nov/12  Updated: 26/Nov/12

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: Benjamin Eberlei 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

 Comment by Lars Strojny [ 26/Nov/12 ] Related:

### [DDC-2166] Improve Identifier hashing in IdentiyMap Created: 25/Nov/12  Updated: 25/Nov/12

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: Benjamin Eberlei Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description
 There are currently some drawbacks with identifier hashing: They only work on one level for derived keys The code is suspect to high performance requirements Composite Keys might be suspect to weird bugs if they contain spaces. There is a PR by goetas (https://github.com/doctrine/doctrine2/pull/232) that solves some issues, however adds a performance hit. We should move the conditional logic of this code out and use a strategy pattern to improve both performance and robustness of this code.

### [DDC-2154] Traits and Code Generation Created: 18/Nov/12  Updated: 18/Nov/12

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

 Description

### [DDC-2141] Query should not be final Created: 13/Nov/12  Updated: 13/Nov/12

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: Tarjei Huse Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None Environment: All

 Description
 The Query class should not be marked final as this makes it impossible to Mock it.

### [DDC-1099] Tutorial :: Getting started code sample entity manager Created: 04/Apr/11  Updated: 11/Jul/11

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

 Type: Documentation Priority: Major Reporter: Gordon Franke Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description
 see pull request 24 on github.com

 Comment by Michael Ridgway [ 11/Jul/11 ] This issue should be closed: https://github.com/doctrine/orm-documentation/pull/24

### [DDC-1089] Annotations reference examples are inaccurate and confusing Created: 30/Mar/11  Updated: 30/Mar/11

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

 Type: Documentation Priority: Major Reporter: Maarten van Leeuwen Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None Environment: N.A.

 Description
 In chapter 19 of the reference guide some coding examples seem to be inaccurate or incorrect. Especially when it comes to the bidirectional many-to-many associations, this might be confusing. Example: The code fragment on http://www.doctrine-project.org/docs/orm/2.0/en/reference/annotations-reference.html#annref-manytomany has the following issues: it does not include class declarations although the collections associated are both mentioned. It should be clear to which target entity they belong and therefore their classes should be declared. from the context it seems that the associated classes should probably be User and Group, and the owning side is User. So the association should probably be inversed by 'users', although the example mentions 'features'. the mapping for the inverse side maps a collection called $features, although this should probably be$users. Also the class declaration for the Group class is missing. Some other code fragments in chapter 19 have similar issues. I think they could easily be replaced by the examples from the earlier chapters, like for the bidirectional man-to-many association the example from chapter 5: http://www.doctrine-project.org/docs/orm/2.0/en/reference/association-mapping.html#many-to-many-bidirectional

### [DDC-1072] Private property mapping can cause issues, suggest changing to protected Created: 17/Mar/11  Updated: 17/Mar/11

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

 Type: Documentation Priority: Major Reporter: Kevin Bradwick Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None Environment: not applicable

 Description
 The documentation recommends using private variables in entities. This can be problematic on entities with relations when using caching drivers as the proxy objects cannot access private variables and so the caching driver can throw notices like ...apc_store(): "_id" returned as member variable from __sleep() but does not exist in ... Making member variables protected resolves this issue when caching is enabled. This information would be helpful on the documentation so others can be made aware of this issue. We spent a few days trying to debug the issue before understanding exactly what was going on.

### [DDC-1739] [GH-314] [WIP] Doctrine\Common metadata drivers reuse Created: 30/Mar/12  Updated: 07/Apr/12

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: Benjamin Eberlei Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Description
 This issue is created automatically through a Github pull request on behalf of Ocramius: Message: This PR is strictly related with https://github.com/doctrine/common/pull/98 and tests won't pass until the doctrine-common submodule points to a merged version of it (will do so later, so please don't merge now ). Basically, I just stripped any code duplicate of what already available in dcom master under Doctrine\Common\Persistence\Mapping\Driver. Tests are OK on my environment when using the new commons submodule. (This is a cleanup for #263, where I sadly did pull from the remote branch after rebasing) Tests are still failing.

 Comment by Benjamin Eberlei [ 30/Mar/12 ] A related Github Pull-Request [GH-314] was synchronize https://github.com/doctrine/doctrine2/pull/314 Comment by Benjamin Eberlei [ 30/Mar/12 ] A related Github Pull-Request [GH-314] was synchronize https://github.com/doctrine/doctrine2/pull/314 Comment by Benjamin Eberlei [ 30/Mar/12 ] A related Github Pull-Request [GH-314] was synchronize https://github.com/doctrine/doctrine2/pull/314 Comment by Benjamin Eberlei [ 30/Mar/12 ] A related Github Pull-Request [GH-314] was synchronize https://github.com/doctrine/doctrine2/pull/314 Comment by Benjamin Eberlei [ 01/Apr/12 ] A related Github Pull-Request [GH-314] was synchronize https://github.com/doctrine/doctrine2/pull/314 Comment by Benjamin Eberlei [ 04/Apr/12 ] A related Github Pull-Request [GH-314] was synchronize https://github.com/doctrine/doctrine2/pull/314 Comment by Benjamin Eberlei [ 06/Apr/12 ] A related Github Pull-Request [GH-314] was synchronize https://github.com/doctrine/doctrine2/pull/314 Comment by Benjamin Eberlei [ 07/Apr/12 ] A related Github Pull-Request [GH-314] was synchronize https://github.com/doctrine/doctrine2/pull/314

### [DDC-1732] Unserialized non-initialized proxy classes should throw an exception when a method is called Created: 28/Mar/12  Updated: 28/Mar/12

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

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

 Attachments: ProxyFactory.php.patch

 Description
 When we serialize entities in a session, we often have pointers to uninitialized proxies. These proxies have $_entityPersister == null. The problem is that if you happen to call by mistake a method on such a proxy, you're not aware that this is an uninitialized proxy, and the business methods are called, with null values for every property. I think the proxy should throw an exception in that case. Attached, a patch with the proposed modification. ### [DDC-1728] There is no exact alternative function like MONTH in mysql Created: 27/Mar/12 Updated: 27/Mar/12 Status: Open Project: Doctrine 2 - ORM Component/s: DQL, ORM Affects Version/s: 2.2.0-RC1, 2.2, 2.2.1 Fix Version/s: None Security Level: All  Type: New Feature Priority: Major Reporter: Sudheesh MS Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None Environment: Ubuntu 11.10  Description  i am not able to extract only month from the date field using doctrine2 using 'MONTH' function ### [DDC-1729] Translate queries into graphs of value objects (instead of array hydration?) Created: 27/Mar/12 Updated: 09/Jun/12 Status: Open Project: Doctrine 2 - ORM Component/s: ORM Affects Version/s: None Fix Version/s: 2.x Security Level: All  Type: New Feature Priority: Major Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None  Description  In decoupled applications the model layer returns "data-transfer-objects" through the boundary into the controller/view layer. It would make sense to have Doctrine directly generate any data-transfer/value-object from native and dql queries.  Comments  Comment by Benjamin Eberlei [ 09/Jun/12 ] Example: $dql = "SELECT new CustomerAddressView(c.id, c.name, a.id, a.street, a.number, a.city, a.code) FROM Customer c INNER JOIN c.address a WHERE c.id = ?1";  This supersedes DDC-1819. 1. One additional property in ResultSetMapping => $viewModelClass? 2. Changes to Parser (new ... syntax) 3. Changes to sQL Walker? 4. Changes to Hydration (Only object hydration!) ### [DDC-1721] LIKE clausule should accept functions on the pattern Created: 21/Mar/12 Updated: 24/Jan/13 Status: Open Project: Doctrine 2 - ORM Component/s: ORM Affects Version/s: 2.1.6 Fix Version/s: None Security Level: All  Type: Improvement Priority: Major Reporter: Ignacio Larranaga Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 1 Labels: None  Attachments: Parser.patch SqlWalker.patch  Description  Example: SELECT .... WHERE upper(n.title) LIKE upper(:filter) should be a valid SQL, now is rejected because the walker only accept a variable or an string expression. I'm adding a patch to address this.  Comments  Comment by Ignacio Larranaga [ 21/Mar/12 ] Sorry the Parser has to be modified also to allow expressions to be recognized, I'm attaching the necessary patch. Comment by Benjamin Eberlei [ 22/Mar/12 ] I am sure there is a reason why the walker doesn't accept this such as not all supported vendors allowing functions in right hand side LIKE expressions, but i am not sure about this. Comment by Glen Ainscow [ 03/Oct/12 ] This is not possible either: WHERE CASE WHEN p.name IS NULL THEN u.username ELSE p.name END LIKE :name Comment by Thomas Mayer [ 24/Jan/13 ] In my case it worked when using "=" instead of "LIKE". //works: (CASE WHEN (Book.id = BookFrom.id) THEN BookTo.displayName ELSE BookFrom.displayName END) = :name //[Syntax Error] line 0, col 1217: Error: Expected =, <, <=, <>, >, >=, !=, got 'LIKE' (CASE WHEN (Book.id = BookFrom.id) THEN BookTo.displayName ELSE BookFrom.displayName END) LIKE :name So the LIKE operator only needs to be allowed here. I'm wondering which vendor should not be able to handle that: The CASE WHEN ... THEN ... END is documented in DQL, and allowed. LIKE itself is allowed. If an RDBMs cannot use CASE WHEN and LIKE in combination, this would be a strange limitation. ### [DDC-1714] Prevent inverse side lazy loading owning side of the oneToOne relationsip if owning side's id is an assosiationKey of inversed side Created: 18/Mar/12 Updated: 18/Mar/12 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: David Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None  Description  This issue was originally discussed in http://www.doctrine-project.org/jira/browse/DDC-357 Say there is User and UserData with oneToOne bidirectional relationship. When we fetch User objects, UserData is lazy loaded right away. If we were to set UserData 's id as asssosiationKey of User, then user_id becomes the id of UserData and User object can already know that UserData owning side's id will equal it's own User->id. Can this be implemented? ### [DDC-1720] SqlWalter private variables should be protected to allow walker extensions Created: 21/Mar/12 Updated: 21/Mar/12 Status: Open Project: Doctrine 2 - ORM Component/s: ORM Affects Version/s: 2.1.6 Fix Version/s: None Security Level: All  Type: Improvement Priority: Major Reporter: Ignacio Larranaga Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None  Attachments: SqlWalker.patch  Description  I'm attaching a patch with the suggestion. ### [DDC-265] Possibility for Nested Inheritance Created: 21/Jan/10 Updated: 16/Jan/13 Status: Open Project: Doctrine 2 - ORM Component/s: ORM Affects Version/s: None Fix Version/s: None Security Level: All  Type: New Feature Priority: Major Reporter: Michael Fürmann Assignee: Roman S. Borschel Resolution: Unresolved Votes: 0 Labels: None Issue Links:  Duplicate duplicates DDC-138 Allow for mixed inheritance mapping Open  Description  It would be great if Doctrine had the possibility to define a further inharitance in a subclass. Example: There is a class DataObject managing things like created- and lastedit- timestamps, archiving objects before updates, ... One of the sub-objects is Content. There are several types of content. Written directly to a database field, read from a textfile on server, executed php file on server, loaded from another server via xmlrpc and so on. I'd like to use a single table inheritance to map all information of the different content objects in one table. If I understand the model right the only alternate solution would be to write each single content object to the discriminator map of DataObject.  Comments  Comment by Benjamin Eberlei [ 21/Jan/10 ] The DataObject you describe is a no-go for Doctrine 2. Its just a very bad practice. Inheritance Mapping is for REAL inheritance only, otherwise you shouldnt go with a relational database in the first place. You should use the Event system for such changes, it offers you roughly the same possibilities and keeps you from having to use inheritance mapping. You could still create an abstract data object and define the fields that will be used in each "implementation" and then in events do something like: if ($entity instanceof DataObject) { $entity->updated();$archiver->makeSnapshot($entity); }  Comment by Jonathan H. Wage [ 20/Mar/10 ] With this patch I think you could setup a nice similar model where you can introduce new children of this parent class and have it added to the discriminator map from the child instead of having to modify the parents mapping information. http://www.doctrine-project.org/jira/browse/DDC-447 ### [DDC-128] Consider adding EntityManager#link/unlink methods for direct association manipulation Created: 07/Nov/09 Updated: 29/Dec/10 Status: Open Project: Doctrine 2 - ORM Component/s: ORM Affects Version/s: 2.0-ALPHA2 Fix Version/s: 2.x Security Level: All  Type: New Feature Priority: Major Reporter: Roman S. Borschel Assignee: Roman S. Borschel Resolution: Unresolved Votes: 1 Labels: None Issue Links:  Reference is referenced by DDC-546 New fetch mode EXTRA_LAZY for collect... Resolved  Description  A problem when working with collection-valued associations is that almost all operations except add($obj) require the collection to become initialized in order for the operation to be performed properly. While this is all correct and beautiful OO-wise it may be problematic at times with regards to performance. Hence we might want to consider to provide some convenient methods along the lines of link/unlink (name suggestions?) which allow more direct, less OO collection manipulation. Such methods obviously would bypass the normal object lifecycle and the changes done through these methods will not be reflected in the in-memory objects and collections, unless the user keeps them in-synch himself.

 Comment by Benjamin Eberlei [ 11/Dec/09 ] Questions I suppose link and unlinked entities would then handled by UnitOfwork commit also? Since the collection is not initialized, one does not know upfront if the action will be successful, what happens if: an entity is linked with a collection, although they are already connected. an entity is unlinked from a collection it is not in. Regarding the naming, i like link/unlink. Comment by Roman S. Borschel [ 17/Dec/09 ] What do you mean by "handled by UnitOfWork commit" ? Whether the SQL is "scheduled" or executed immediately? Interesting question. Scheduling would probably be better but also more difficult. As far as usage is concerned, I currently imagine it as follows: // EntityManager#link($sourceObj,$field, $targetObj)$user = $em->getReference($userId); // $userId probably from request parameters$address = $em->getReference($addressId); // $addressId probably from request parameters$em->link($user, 'addresses',$address);  "What happens if: an entity is linked with a collection, although they are already connected." Probably an SQL error which results in an exception from the driver. Depends on the database constraints though. "What happens if: an entity is unlinked from a collection it is not in" Probably nothing, at least not from the SQL side. An exception could be thrown from Doctrine itself if the update affected 0 rows. Thanks for these initial questions. Thats definitely food for thought. Keep it coming. Comment by Roman S. Borschel [ 26/Aug/10 ] Pushed back.

### [DDC-586] Repo does not find "unflushed" object Created: 14/May/10  Updated: 26/Aug/10

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

 Type: Improvement Priority: Major Reporter: John Kleijn Assignee: Roman S. Borschel Resolution: Unresolved Votes: 0 Labels: None

 Description
 The problem is this: $bar = new \entity\content\ContentTag();$bar->setName('bar'); $em->persist($bar); $existingTag =$em->getRepository('entity\content\ContentTag')->findOneByName('bar'); Seeing as in EntityRepository "find()" queries the Unit of Work first, and "findBy()" goes directly to the persister, only remotely stored objects will be found. Now if I want a tag object to attach related tags, it would have to query by name to see if an object already exist, BUT it wont find one as the UoW has not been committed, resulting in a new one being created, ultimately resulting in a PDO error on the unique name constraint. This can be "solved" by inserting a flush, but it is impossible to know whether a flush is required, without knowledge of what comes next. I.e. for one part to know it has to flush, it has to know another wants to fetch an object you just created. This causes an unacceptable amount of coupling. Somehow the repo will have to be able execute DQL against the objects in the UoW. This does not have to be full support (straight away), but it should fail (throw an exception) if the possibility exists that the UoW contains items that are excluded (e.g. the operation is not supported and the UoW still contains items). For right now, this means the EntityManager should throw an exception if DQL is executed on the type when the UoW is not empty. Until the time that the EntityManager can query the UoW using DQL. The alternative would be to "flush" before every operation that goes to the database for data.

 Comment by Roman S. Borschel [ 14/May/10 ] Hi, you mention a good point, however, this currently only affects findBy queries made through a repository. A DQL query already triggers a flush when there are pending insertions but this still has its own problems. First of, querying against the objects in the UoW is not a viable solution in my eyes. For a regular find() (by identifier) the situation is clear anyway, you must flush prior to a lookup on an entity you previously persisted in the same request because, by definition, generated primary key values are only guaranteed to be available after the next flush. Automatic flushing if the UoW has pending inserts (new objects) and a query is executed (either through DQL or a repository) currently has its own set of problems, namely that it is still subject to infinite recursion if such a query is triggered in an event (listener) that executes during commit of a UoW, and secondly, that it will easily lead to double-flushes that cause unnecessary overhead (currently a flush() even if nothing needs to be done is not free because the UoW actually has to check whether nothing needs to be done). Both of these problems could be addressed with some sort of flags, but the question still is whether its not better to flush manually in the first place. That would mean, in your example, you should flush after persisting the new objects, irrespectively of what code comes next, you persisted (a) new object(s) and you want to make sure these are fully available to the rest of the script. Comment by Roman S. Borschel [ 14/May/10 ] Furthermore, automatic flushing when there is no transaction active is probably also not a great idea, as it may split a single unit of work (that was supposed to be atomic) into 2 without the user knowing about it. So auto-flushing should better only happen when a transaction is active (i.e. explicit transaction demarcation is used). Comment by John Kleijn [ 14/May/10 ] That would mean, in every example, you should flush after persisting new objects, period. If I flush in some cases and not in others, I'm asking for issues that may not be caught by tests. It's an inconsistency that I personally am not comfortable with. Could be that I'm overlooking something, I've just started playing with D2. Why is querying against registered objects not viable? It's not easy, granted, but it doesn't seem impossible. There should probably be a layer between the UoW and the "persisters" (Data Mappers?). RE: the UoW double flush: state management on the UoW as a whole should prevent that. i.e. after a commit the whole UoW is clean? Just a suggestion, as I said, still getting my bearings. On a side note I just want to say that what I've seen so far, for the better part, pleases me greatly. Kudos. Comment by Roman S. Borschel [ 14/May/10 ] @"That would mean, in every example, you should flush after persisting new objects, period." Yes, if you want the objects to be visible to queries in the same request. Generally, you should flush when you complete a unit of work and that is usually not the whole request (but can be). I don't want to "query" against registered objects because it is a) not easy b) likely a lot of code and c) very likely error-prone. And in addition I don't see this helping with solving any inconsistency. If you want to use find() you have to flush anyway because you can not find() without having the identifier in the first place, which is only available after a flush. @RE: the UoW double flush: Yes, like I said, it can be done but it is a compromise. Having a "clean/dirty" flag in addition to calculating the changesets of the work to do (which implicitly tells us whether the UoW is dirty) adds more code and more potential for errors. Forget to update the flag in one location and you get flushes that don't do anything, because the flag was not updated. A dirty-flag for the UoW is not really required for proper working. It is similar to the approach of maintaining a separate counter for the number of elements in a collection implementation: can make many size/count requests faster but complicates the internal implementation and increases the likelihood for errors (and lock contention for the counter in a thread-safe/concurrent implementation, an interesting case where performance goes against scalability, but I digress and that does not apply to php obviously). That said, I am not strongly opposed to doing this. If you're interested in how this is specified by "big brother", take a look at section 3.8.7 of the JPA 2 specification. Shortly, with the default behavior it requires the implementation to ensure that unflushed changes are visible to queries which can be achieved by flushing these to the database automatically but only if a transaction is active, otherwise the implementation must not flush to the database. There is alternatively also a "MANUAL" flush mode, in that case the effect of updates made to entities in the UoW upon queries is unspecified. We do not have different flush modes anymore, however, in Doctrine. So I see two possible ways to go here: 1) More effort, more code, (really better?) Maintaining a dirty flag in the UoW (this could be done anyway at some point, even if 2) is chosen) Maintaining a flag to avoid infinite recursion triggered from events within a UoW commit/flush Flushing automatically when querying while there are pending inserts and a transaction is active 2) No effort, less code Removing the current auto-flush on DQL queries which is still subject to infinite recursion No automatic flushes, anywhere (less magic, so to speak?) Clearly documenting that new, unflushed entities are not visible in subsequent queries issued in the same request, and if this is desired, a flush should be issued. That's how I see it. Now we need some votes and volunteers for the implementation Personally, I am not sure yet about which version I prefer, 2) does not sound too bad for me. Comment by Roman S. Borschel [ 14/May/10 ] In Nr. 1) the case with the infinite recursion may actually be more problematic. I think you simply can not see unflushed new objects in queries made during a UoW commit. Comment by John Kleijn [ 14/May/10 ] When there's no in-memory objects inclusion, I'd say 2) as well. Again, I have no idea how this is implemented currently, but I would prefer something like this: $repo->start();$repo->register($object);$repo->commit(); Why? Commit instead of flush: "flush" has little semantic value IMO, "commit" leaves no questions: you're committing your changes (which implies that they are not, before) Operating on the repo leaves no question to what you are committing: changes of the associated type and relations configured to cascade, made after start() Register instead of persist: "persist" is misleading as the object is not immediately persisted, and as my example shows, may not be. The way I see it "start" would create a UoW associated with the repo, "commit" would calculate changes and write (the enitity manager would make sure references in other UoWs are removed). Because the way it is currently implemented (or so it seems), it's unclear when to flush and when not to flush, and unclear what I'm flushing at any one point in the code (because it is not locally isolated). If I have to decide whether to flush in some bit of client code, I am apparently making an assumption about the target entity, i.e. coupling. I know, you already went beta, so it's unlikely you would consider such a large change, but anyway, for your consideration. Finally, I realize I'm borderline nagging now as you've made it clear you see nothing it, but a Repository (as in the PoEAA pattern, p 322) may provide a method of fetching native in-memory objects using criteria, acting as a "buffer" between code and database. The Repository in D2 does effectively nothing but delegate to the UoW (or mostly to the underlying persister). Ref PoEAA 327 for an example of an in-memory strategy. As a final point of critique, the Repository does not always seem to be used as entry point for data requests, which is the whole point of the pattern. Most of what's in EntityManager, should be in EntityRepository ("manager" is a bit to abstract a concept to expect clear responsibilities anyway). EntityManager::find() delegates to EntityRepository, but pretty much everything else is the other way around. EntityManager would be better off named DataGateway, as that accurately describes its intended function. I admit, it would be very difficult to use DQL on in memory objects, but it would be far superior and if it work lead to much more predictable behaviour. It's the ONLY way the data store is ever going to be truly transparent. A few examples (DQL from the docs): SELECT u, UPPER(u.name) nameUpper FROM MyProject\Model\User u Fetch everything from the db Select all objects from the User UoW Iterate over the in memory ones and modify the name property to upper case Merge the results and return SELECT u FROM User u WHERE u.id = ?1 OR u.nickname LIKE ?2 ORDER BY u.surname DESC Execute against database Iterate over the User UoW, indexing by "surname", adding items that match the criteria Merge the results and return With joins it could get more complex, provided you want to intelligently merge results into existing objects. Question is whether that is really needed, but there's obviously a performance benefit. Actually this may already be implemented. I suspect there are edge cases, rooted in DQL still being based on SQL, but in theory it should be possible. Likely you would still want to do start(), and delegate to the driver to start an actual transaction to prevent inconsistent reads... The only way to find out if it's truly feasible is to to try it, I think. Ramble, ramble, ramble, I'm done. I know I seem critical, but it's positive critique, I love the direction you went with D2. Comment by Roman S. Borschel [ 14/May/10 ] Maybe I was not clear, with approach Nr.1 there would be in-memory objects inclusion (of new objects), in fact, there always is, due to the identity map. When you query for objects and some of them are already in memory, these are used, not again reconstructed. The EntityRepository provided by Doctrine is just a convenient mechanism for writing your own repositories. There are many different understandings for what a repository is, you can make it whatever you want it to be. Is a PoEAA repository the same as a DDD repository? Anyway, the repository could be stripped of the project, it is optional, the state management is handled by the EntityManager and UnitOfWork. These are the core components. I agree that the delegation from EntityManager#find to the repository is suboptimal in this regard and should be the other way around. Now to your question: "When should I flush?". Generally, you should flush at the end of a transaction, which in turn is a unit of work. That means, use explicit transaction demarcation. begin() ... flush() commit(). I've added some control abstractions recently that should make this even easier. I can only recommend to explicitly demarcate your transaction boundaries. As you probably know, you can not talk to your database outside of a transaction anyway. The default behavior (flush() wrapping all its stuff in a transaction) is for convenience mostly and so as not to alienate or confuse people even more who are used to autocommit mode. Concerning the naming, we mostly stick with the JPA specification and I, for one, really like the naming and I don't want to invent new names. PoEAA is far more abstract (and the examples far too specific) than what is specified in JPA, so I recommend giving that a read. The patterns in PoEAA obviously and intentionally leave a lot of room for different variants of implementation and also leave open a lot of open questions (many of the difficult questions especially, it is for a reason that the author recommends using an existing tool instead of writing your own). In my opinion it is just not feasible to query in-memory objects in a generic way, all the examples in PoEAA do not have generic but rather concrete code examples, which is obviously a lot easier. The feasible strategy, and that is what we do, is to do in-memory lookups only when querying by PK, otherwise the query is executed and afterwards nevertheless any objects reused that are already in memory (based on the PK) and not reconstructed. This is the approach we use. Thanks for your input, I do see that you are an experienced fellow in object-relational persistence, maybe we can see you as a committer some day? Comment by Roman S. Borschel [ 14/May/10 ] @ "SELECT u, UPPER(u.name) nameUpper FROM MyProject\Model\User u" This selects all users and their names in uppercase, the uppercase names are scalar values, the users are not modified! Scalar values are separate from objects. @ "... and unclear what I'm flushing at any one point in the code" flush() means: Synchronize the in-memory state of my objects with the database, making any changes that are only in-memory persistent. Nothing more, nothing less. Again, objects are always reused based on the identity map and the state that is in-memory prevails, unless you use refresh() or execute a query with the Query::HINT_REFRESH query hint. All objects you fetch from DQL, be it as a root object or as a joined association, are first looked up in-memory (but after the SQL query has been issued!). Maybe we have been talking past each other here, what I refer to as not feasible is querying the in-memory objects first in some way, even before the SQL query. This is just too complicated and error-prone, except for the simple case of a PK lookup and that is where we do it already. Comment by John Kleijn [ 14/May/10 ] > Scalar values are separate from objects. Right. Bad example. > flush() means: Synchronize the in-memory state of my objects with the database, making any changes that are only in-memory persistent. Nothing more, nothing less. I realize that it means that, but commit() would be more obvious. > Maybe we have been talking past each other here, what I refer to as not feasible is querying the in-memory objects first in some way, even before the SQL query. This is just too complicated and error-prone, except for the simple case of a PK lookup and that is where we do it already. Fair enough, you don't think it's feasible, so we'll keep it at that. Maybe I'll give it a shot some time.

### [DDC-536] Remove the _ prefix from private and protected members Created: 23/Apr/10  Updated: 19/Nov/10

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

 Type: Task Priority: Major Reporter: Roman S. Borschel Assignee: Roman S. Borschel Resolution: Unresolved Votes: 1 Labels: None

 Description
 The reasoning is simple: The prefix "_" is usually either used for easier distinction of instance variables from other, i.e. local variables, instead of always using "this." (often seen in C#), or it is used to signal that a member is not meant to be accessed from outside of the class when the language does not have visibility modifiers (PHP4). Since you always have to use "$this->" in PHP5+ when accessing instance members and there are visibility modifiers, the "_" is largely superfluous and just makes the verbose OO code even more verbose. Maybe the following find/replace steps will do the job almost completely: "private$_" => "private $" "protected$_" => "protected $" "$this->_" => "$this->"   Comments  Comment by Benjamin Eberlei [ 27/Apr/10 ] i just found a possible BC issue with this. EntityRepository is allowed to be extended by us, it has several variables that are underscore prefixed. How to proceed in this case? Comment by Roman S. Borschel [ 27/Apr/10 ] I know but its not really a problem I think. We should just decide whether we make them private in the first place and provide getters instead (which would have avoided this problem in the first place). Comment by Roman S. Borschel [ 27/Apr/10 ] Leaving the prefixes on the repository class only is also an option... but I dont think thats necessary. Comment by Benjamin Eberlei [ 27/Apr/10 ] can we commit getters for Beta 1 then? We could give everyone a period until Beta 2 to fix their code and then make the change. EntityRepository is the only class that is meant to be userland extendable to my knowledge, so this should be the only problem to adress Comment by Roman S. Borschel [ 27/Apr/10 ] Yes, you can add getters and commit right away if you want. Plus adding a note on the upgrade document that direct access of these properties is deprecated. Comment by Roman S. Borschel [ 27/Apr/10 ] Persisters will be also extensible some day in userland but they need more polish for that, I've already started with it Comment by Johnny Peck [ 19/Nov/10 ] Is this still planned? Searching the code base finds this is not being implemented. It would be a good idea to implement the change sooner than later if it will be done at all. Also, +1 for the change. It makes complete sense. ### [DDC-763] Cascade merge on associated entities can insert too many rows through "Persistence by Reachability" Created: 23/Aug/10 Updated: 04/Jul/11 Status: Open Project: Doctrine 2 - ORM Component/s: ORM Affects Version/s: None Fix Version/s: 2.x Security Level: All  Type: Improvement Priority: Major Reporter: Dave Keen Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 2 Labels: None  Attachments: 0149-DDC-763.patch DDC763Test.php multipleaddmerge.diff  Description  I think that the UnitOfWork needs to maintain a map of spl_object_hash($newEntity)->$managedEntity for entities that were persisted via reachability during a merge. doMerge should then only call persistNew if the original entity has not already been persisted (if it has already been persisted it should merge the managed entity from the map). The map should be maintained until a flush() or until the UnitOfWork is cleared. The reasoning is as follows. Imagine we have a simple doctor object with no associations: $doctor = new Doctor(); $em->persist($doctor); $em->persist($doctor); $em->flush();  After the first persist()$doctor is MANAGED so the second persist has no effect and this results in a single Doctor row. If we do the same thing using merge and persistence by reachability: $doctor = new Doctor();$em->merge($doctor);$em->merge($doctor);$em->flush();  we get 2 Doctor rows being added. Obviously in this particular case we should use the return value from the first merge() as the parameter of the second merge which would give correct behaviour. However, now imagine one Doctor has many Patients and many Patients have one Doctor, all the associations have cascade merge enabled, and further assume that $d1 (Doctor id=1) is already in the database. We now attempt to create two patients and assign them to the existing doctor: $d1= new Doctor(); $d1->id = 1; // This is a DETACHED entity$p1 = new Patient(); $p2 = new Patient();$d1->patients->add($p1);$p1->doctor = $d1;$d1->patients->add($p2);$p2->doctor = $d1;$em->merge($p1);$em->merge($p2);$em->flush();  This actually results in 4 rows being added to the 'patients' table instead of 2, I think because $p1 and$p2 are getting persisted both as the root objects and then again from the patient->doctor->patients array. Since the cascade merging happens internally we can't replace the array contents with the managed return values without walking through the object graph (in which case there is no point in using cascade merge in the first place). Maintaining a map in UnitOfWork will allow doMerge to ensure it doesn't persist the same entities twice. I'm not sure, but this might be relevant for cascade persist too. P.S. Another bug report on this can be found at http://code.google.com/p/flextrine2/issues/detail?id=32 (it basically says the same thing with different entities).

 Comment by Benjamin Eberlei [ 29/Aug/10 ] @Roman A possible fix for this in my opinion is another map in UnitOfWork $mergedEntities = array(); and a patch like this: diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 242d84b..1d0d8b3 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -1340,6 +1340,10 @@ class UnitOfWork implements PropertyChangedListener return; // Prevent infinite recursion } + if (isset($this->mergedEntities[$oid])) { + return$this->mergedEntities[$oid]; + } +$visited[$oid] =$entity; // mark visited $class =$this->em->getClassMetadata(get_class($entity)); @@ -1468,6 +1472,8 @@ class UnitOfWork implements PropertyChangedListener$this->cascadeMerge($entity,$managedCopy, $visited); +$this->mergedEntities[$oid] =$managedCopy; + return $managedCopy; }  Comment by Dave Keen [ 29/Aug/10 ] I have tested this patch with my application and it fixes the problem in all my relevant test cases apart from one. The test case that's failing is one that persists a bi-directional many to many relationship, so the associations interweave with each other (if you know what I mean). I wonder if perhaps doMerge need to continue cascading even if it finds an item in$this->mergedEntities This is the Flextrine code that fails - it results in no entries in movie_artist. This might also be related to DDC-758? m1 = new Movie(); m1.title = "Movie 1"; m2 = new Movie(); m2.title = "Movie 2"; a1 = new Artist(); a1.name = "Artist 1"; a2 = new Artist(); a2.name = "Artist 2"; m1.artists.addItem(a1); a1.movies.addItem(m1); m1.artists.addItem(a2); a2.movies.addItem(m1); m2.artists.addItem(a1); a1.movies.addItem(m2); m2.artists.addItem(a2); a2.movies.addItem(m2); // These translate to cascade merges on the server em.persist(m1); em.persist(m2); em.persist(a1); em.persist(a2); // Now flush em.flush(); Comment by Dave Keen [ 29/Aug/10 ] P.S. This test passes if I translate em.persist() to $em->persist() (not cascading) on the server instead of translating it to a cascade merge; not sure if that helps Comment by Roman S. Borschel [ 30/Aug/10 ] I'd really like to avoid introducing an additional instance variable just to solve this issue but I did not find the time yet to really look into it. Does someone have a unit test for this already and can attach it to the issue? Comment by Roman S. Borschel [ 31/Aug/10 ] Rescheduling for RC1. Comment by Dave Keen [ 13/Sep/10 ] Here is a functional test case containing three tests: testMultiMerge tests basic merging of two new entities, checking that only a single entity ends up in the database. This passes with Benjamin's patch. testMultiCascadeMerge tests the more complex case of merging a OneToMany association. This also passes with Benjamin's patch. testManyToManyPersistByReachability tests the ManyToMany case described above and this fails with Benjamin's patch, probably because doMerge doesn't cascade down entities that it has already merged and some ManyToMany associations are being ignored. Its a bit hard to be certain what is causing this as even without Benjamin's patch this test would fail due to DDC-758. Comment by Benjamin Eberlei [ 15/Sep/10 ] @Roman i thought about this issue, its not possible without that additional map of merged entities. There is no way we can get that information from other sources. Problem is rather that the use-case probably only applies in mass-merging scenarios and client-server serialization. Comment by Dave Keen [ 21/Sep/10 ] Added another failing test case - adding the same entity from different ends of a many to many bi-directional association to check that there isn't an integrity constraint violation caused by Doctrine trying to add the same row twice. Comment by Dave Keen [ 21/Sep/10 ] Attached a patch for this issue. Comment by Benjamin Eberlei [ 22/Sep/10 ] can you comment why all the additionall stuff is necessary compared to my patch? Comment by Dave Keen [ 22/Sep/10 ] It fixes the two additional test cases - testManyToManyPersistByReachability and testManyToManyDuplicatePersistByReachability. testManyToManyPersistByReachability was failing with your original patch because there are ManyToMany cases where an entity may have already been merged, but its still necessary to add it to an association and continue to cascade. Running the following with the original patch will miss out some of the associations. $m1 = new Movie(); $m1->title = "Movie 1";$m2 = new Movie(); $m2->title = "Movie 2";$a1 = new Artist(); $a1->name = "Artist 1";$a2 = new Artist(); $a2->name = "Artist 2";$m1->artists->add($a1);$a1->movies->add($m1);$m1->artists->add($a2);$a2->movies->add($m1);$m2->artists->add($a1);$a1->movies->add($m2);$m2->artists->add($a2);$a2->movies->add($m2);$em->merge($a1);$em->merge($a2);$em->flush();  The other change in my patch is to protect against this case. It ensures that the following code doesn't add the same entity twice to a collection. $em->merge($m1); $em->merge($m2); $em->merge($a2); $em->merge($a2); $em->flush();  Comment by Benjamin Eberlei [ 31/Oct/10 ] I am not sure if the issue here is rather multiple calls to merge that contain different parts of the same object-graph. There should be a very simple fix for this, call ->clear() after each merge. I am not sure if this patch drags us into a blackhole of issues with merging. Comment by Dave Keen [ 31/Oct/10 ] Calling ->clear() and ->flush() after each merge is a workaround for the simple case, but unless I am misunderstanding I don't think its a solution for cases where the merging is happening automatically in cascadeMerge. I've actually encountered this issue in another project and scenario to do with creating REST APIs and merging JSON objects into entities, and applying the patch fixed it so a) I think this issue might be a more common that we first thought and b) the patch basically seems to work (plus it doesn't introduce any failing cases in the existing test suite). I can actually still find one edge case to do with cascading merging interlinked many to many associations that this doesn't fix, but I was planning to open that as a new ticket after this My feeling is that the current merge already has issues and this definitely improves it. Comment by Benjamin Eberlei [ 01/Nov/10 ] It cannot happen inside a single merge, single merges use the$visited to avoid infinite recursions, each entity can only be merged once inside a single merge operation. Comment by Benjamin Eberlei [ 10/Nov/10 ] Added a note into the documentation about using EntityManager#clear between merging of entities which share subgraphs and cascade merge. Handling this issue in UnitOfwork will be declared an improvement, not a bug anymore and be scheduled for later releases. The required changes to the core are to dangerous and big. Comment by Dave Keen [ 11/Nov/10 ] Where in the docs is that? Just to summarize, the equivalent operation to having multiple merges and a single flush is to call merge followed by flush each time, with the whole thing surrounded by a transaction? Does this have a big impact on performance? Comment by Dave Keen [ 11/Nov/10 ] Ben - even given the decision not to implement this (and I do understand your thinking, as it is a major change), is there any reason not to implement the bit that ensures that the same entity isn't added to a collection twice during a merge? I can't think of a situation where this should be allowed, and I have a use case where I get 'DUPLICATE KEY' errors if this isn't there. Please see attached patch. Comment by Benjamin Eberlei [ 11/Nov/10 ] What bit of that huge patch is that? Can you extract it into another ticket if thats possible? Comment by Benjamin Eberlei [ 11/Nov/10 ] I added it to "Working with Objects" and the descripton of Merge. Its not yet live on the site. Using this current workaround has a performance impact, since more SELECT statements have to be issued against the database. Comment by Dave Keen [ 11/Nov/10 ] Apologies for not being clear - only the 3rd patch (multipleaddmerge.diff) is relevant to the 'DUPLICATE KEY' error I am now talking about, but I'll put it in a nother ticket if you prefer. Comment by Benjamin Eberlei [ 11/Nov/10 ] please add a new ticket, patch looks good. Comment by Dave Keen [ 11/Nov/10 ] Created as DDC-875

### [DDC-726] DQL should deal correctly with composite primary keys Created: 30/Jul/10  Updated: 04/Oct/11

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

 Type: Improvement Priority: Major Reporter: Guilherme Blanco Assignee: Guilherme Blanco Resolution: Unresolved Votes: 1 Labels: None

 Duplicate is duplicated by DDC-1162 Add support for multi-column IN state... Resolved

 Description
 DQL should deal correctly with composite primary keys: SELECT u FROM User u WHERE u.CompositeAssocEntity = ?1 Should be converted to: SELECT ... FROM users u WHERE (u.cae_id1, u.cae_id2) = (?, ?) // or something similar  It also supports IN expressions: SELECT u FROM User u WHERE u.CompositeAssocEntity IN (?1, ?2) Should be converted to: SELECT ... FROM users u WHERE (u.cae_id1, u.cae_id2) IN ((?, ?), (?, ?)) // or something similar  MySQL, SQLite and PgSQL works smoothly. Need to check out MSSQL, Oracle and DB2.

### [DDC-688] Original Entity Data gets overridden by the change set Created: 12/Jul/10  Updated: 28/Dec/10

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

 Type: Improvement Priority: Major Reporter: Jasper Kuperus Assignee: Roman S. Borschel Resolution: Unresolved Votes: 0 Labels: None Environment: Mac OS X 10.6; PHP 5.3.2; MySQL 5.1.44

 Description
 When changing data in an entity, the UnitOfWork will call computeChangeSet on a flush event. If there is a changeset, the original data ($this->_originalEntityData) gets overridden by the new data. However, the _originalEntityData should hold the original data, that was present at the time the entity was reconstituted from the database. This does no longer hold now. I think this can simply be fixed by commenting this line, however I do not know of any consequences this may bring with it:$this->_originalEntityData[$oid] =$actualData; (in computeChangeSet, after if( $changeSet )); Anyway, I ran into this problem while trying to retrieve the original data at the onFlush event of an update.  Comments  Comment by Roman S. Borschel [ 08/Aug/10 ] This is actually currently expected. You can not get access to the original data in the onFlush event right now. I'm not saying that this will never be possible but it is simply the way it works at the moment. Comment by Jasper Kuperus [ 08/Dec/10 ] Does this mean that it is currently impossible to implement a Versionable mechanism using snapshots? Comment by Benjamin Eberlei [ 09/Dec/10 ] You can hold a map of them yourself if your listener also implements the "postLoad" event: $entity = $args->getentity();$this->originalData[spl_object_hash($entity)] =$args->getEntityManager()->getUnitOfWork()->getOriginalData($entity);  Comment by Benjamin Eberlei [ 28/Dec/10 ] Changed into possible improvement for the future ### [DDC-683] EntityManager#lock() on unitialized proxy coudl be optimized Created: 10/Jul/10 Updated: 21/Jul/10 Status: Open Project: Doctrine 2 - ORM Component/s: ORM Affects Version/s: 2.0-BETA2 Fix Version/s: None Security Level: All  Type: New Feature Priority: Major Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None Issue Links:  Reference relates to DDC-681 PATCH: UnitOfWork#lock locks by colum... Resolved  Description  If you call lock() on an unitiialized proxy, it would be possible to combine the fetch and lock in one operation. Is this feasible from a technical / workflow perspsective?  Comments  Comment by Benjamin Eberlei [ 21/Jul/10 ] Ok this is what refresh() with LOCK support is actually needed for:  public function lock($entity, $lockMode,$lockVersion = null) { if ($this->getEntityState($entity) != self::STATE_MANAGED) { throw new InvalidArgumentException("Entity is not MANAGED."); } else if ($entity instanceof Proxy &&$entity->__isInitialized__) { $this->refresh(....); // with LOCK! } ... }  ### [DDC-676] Find a way to test serialize/unserialize of all ClassMetadata properties in isolation Created: 10/Jul/10 Updated: 29/Aug/10 Status: Open Project: Doctrine 2 - ORM Component/s: ORM Affects Version/s: None Fix Version/s: 2.x Security Level: All  Type: Improvement Priority: Major Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None  Description  We should find a way, using PHPUnit Data Providers or anything else, to check the serialize/unserialize of every property in the ClassMetadata instance, since errors here can be very subtle but dangerous. ### [DDC-678] OneToMany/OneToOne + onDelete=CASCADE may corrupt UoW. Created: 10/Jul/10 Updated: 05/Jun/11 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: Roman S. Borschel Assignee: Roman S. Borschel Resolution: Unresolved Votes: 0 Labels: None  Description  OneToMany/OneToOne associations together with an onDelete=CASCADE schema generation hint on the @JoinColumn and appropriate foreign key constraints can potentially result in a corrupt UoW if the associated objects are already managed. We need to add tests for such scenarios and settle on a well-defined behavior in such cases.  Comments  Comment by Benjamin Eberlei [ 31/Oct/10 ] I think to preserve the semantics the following has to happen: "on-delete" => "cascade" has to implicitly set cascade = remove. This hurts performance of course vs just using the on-delete, however it won't corrupt the UoW. Comment by Benjamin Eberlei [ 02/Jan/11 ] Not entirely would it hurt performance, you could check if on-delete => cascade is set. If this is the case you wouldnt need to do an explicit remove using the UnitOfWorks cascade. Comment by Benjamin Eberlei [ 05/Jun/11 ] Changed to improvement ### [DDC-667] Lock Timeout Query Hint for DQL Queries Created: 04/Jul/10 Updated: 16/Sep/10 Status: Open Project: Doctrine 2 - ORM Component/s: ORM Affects Version/s: 2.0-BETA2 Fix Version/s: 2.x Security Level: All  Type: New Feature Priority: Major Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None  Description  After the implementation of DDC-178 there is now only outstanding the support for locking queries based on a given timeout. This will be a DQL query feature only and be available via a query hint: $query->setHint(Query::LOCK_TIMEOUT, $timeoutMs);  It will be only working on Oracle.  Comments  Comment by Roman S. Borschel [ 30/Aug/10 ] If this is to be implemented for 2.0, it needs to happen for RC1, therefore rescheduling to RC1. Feel free to reschedule to 2.x if necessary. Comment by Benjamin Eberlei [ 16/Sep/10 ] Only oracle supports lock timeouts and no other vendor seems to plan to support it. I move to 2.x, but i guess this would rather be an issue of user extension. Allow @Id on @ManyToOne fields (DDC-117) ### [DDC-658] Reverse engineering with Oracle (DBDriver and Associations as Identifier) Created: 27/Jun/10 Updated: 11/Dec/11 Status: Open Project: Doctrine 2 - ORM Component/s: ORM Affects Version/s: None Fix Version/s: 2.x Security Level: All  Type: Sub-task Priority: Major Reporter: Mickael Perraud Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 1 Labels: None Environment: Ubuntu 10.04 + Oracle 11g Entreprise + PHP 5.3.2 + Doctrine2 Git (up-to-date)  Description  I am playing with reverse engineering with Oracle and I have some problems: My schema: drop table PHONE_NUMBER; drop table CUSTOMER; create table CUSTOMER ( CUSTOMER_ID NUMBER(4) not null, CUSTOMER_LASTNAME VARCHAR2(50) not null, CUSTOMER_MODIFIED DATE, constraint PK_CUSTOMER primary key (CUSTOMER_ID) using index tablespace TBS_INDEX storage ( initial 100K next 100K ) ) storage ( initial 100K next 100K ) tablespace TBS_DATA; create table PHONE_NUMBER ( PHONE_NUMBER_ID NUMBER(4) not null, CUSTOMER_ID NUMBER(4) not null, PHONE_NUMBER VARCHAR2(50) not null, PHONE_NUMBERMODIFIED DATE, constraint PK_PHONE_NUMBER primary key (PHONE_NUMBER_ID, CUSTOMER_ID) using index tablespace TBS_INDEX storage ( initial 100K next 100K ) ) storage ( initial 100K next 100K ) tablespace TBS_DATA; alter table PHONE_NUMBER add constraint PHONE_NUMBER__CUSTOMER foreign key (CUSTOMER_ID) references CUSTOMER (CUSTOMER_ID);  I obtain "Fatal error: Uncaught exception 'Doctrine\ORM\Mapping\MappingException' with message 'Property "customerId" in "PhoneNumber" was already declared, but it must be declared only once'" It's because a foreign key is a component of the primary key.  Comments  Comment by Mickael Perraud [ 28/Jun/10 ] This is the continuation of http://www.doctrine-project.org/jira/browse/DDC-616. Only the schema is different. Comment by Benjamin Eberlei [ 28/Jun/10 ] just for understanding this scenario: Is this a One-To-One relation and the TABLE_TEST2 "inherits" the primary key from its parent TABLE_TEST1? If yes, this construct is not yet supported by Doctrine 2, we still need to include an ID-Generator that supports this kind of schema. Comment by Mickael Perraud [ 28/Jun/10 ] Change for a more understandable use case. Note that it's not my real use case and that I work on legacy database on which I can't change the structure. Comment by Benjamin Eberlei [ 01/Jan/11 ] updated the issue topic to get a better grasp of what needs to be done here. Comment by waldo [ 09/Jun/11 ] I have the same error with Mysql whit the same condition. Comment by Benjamin Eberlei [ 28/Nov/11 ] More details on the work to be done: The relevant code is in Doctrine/ORM/Mapping/Driver/DatabaseDriver.php only. The idea is currently many-to-many tables are detected by checking that the table has foreign keys on all the primary key columns (no additional columns!) Now with the 2.1 feature of foreign key/primary key entities this is not necessarily true anymore. You can have the primary keys being foreign keys BUT have additional columns that are not part of the primary key. This has to be detected. If a foreign key-primary-key entity is found that has additional columns a ClassMetadata has to be created and the associations have to be created with the "id" => true flag in mapManyToOne(). Comment by Scott Steffens [ 11/Dec/11 ] For what it's worth, I'm getting this error when I have a PK that is a single column and not a FK. PRIMARY KEY (id), UNIQUE KEY cycle_station_id (cycle,station_id), KEY station_id_idx (station_id), KEY readings (readings), KEY source (source), KEY temperature_min_max (temperature_max,temperature_min), KEY station_id_cycle (station_id,cycle,updated_at), CONSTRAINT compiled_1_station_id_stations_id FOREIGN KEY (station_id) REFERENCES stations (id), CONSTRAINT compiled_1_station_id_stations_id_1 FOREIGN KEY (station_id) REFERENCES stations (id) ON DELETE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=160833690 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ### [DDC-624] Partial object query that leaves out an association to avoid loading it fetches the association anyway. Created: 03/Jun/10 Updated: 11/Nov/11 Status: Open Project: Doctrine 2 - ORM Component/s: None Affects Version/s: 2.0-BETA1 Fix Version/s: 2.x Security Level: All  Type: Bug Priority: Major Reporter: Roman S. Borschel Assignee: Roman S. Borschel Resolution: Unresolved Votes: 2 Labels: None Issue Links:  Duplicate is duplicated by DDC-1465 Fetching partial objects doesn't work... Open  Description  Assuming: Customer Cart where Cart is the owning side. Since the association from Customer to Cart can not be lazy, it would make sense to leave out the association in a query to avoid loading the carts like this: select partial c.{id,name, ... anything except cart} from Customer c"  But this is ignored and the carts of all customers are fetched anyway. Query::HINT_FORCE_PARTIAL_LOAD is an alternative solution, however it has the disadvantage that it disables lazy-loading for all queried objects. If partial querying would honor associations this would allow more fine-grained control.  Comments  Comment by Roman S. Borschel [ 26/Aug/10 ] Might need to be pushed back to a 2.0.x / 2.x.x bugfix release. Not clear yet. ### [DDC-138] Allow for mixed inheritance mapping Created: 12/Nov/09 Updated: 24/Dec/10 Status: Open Project: Doctrine 2 - ORM Component/s: DQL, Mapping Drivers, ORM Affects Version/s: None Fix Version/s: None Security Level: All  Type: New Feature Priority: Major Reporter: Reinier Kip Assignee: Roman S. Borschel Resolution: Unresolved Votes: 2 Labels: None Issue Links:  Duplicate is duplicated by DDC-265 Possibility for Nested Inheritance Open  Description  Requesting implementation of mixed inheritance mapping (class table inheritance and single table inheritance). This would be especially handy when the difference between certain classes is only "implementational" (i.e. a subclass only functions differently/implements abstract methods and does not specify any additional fields). Using class table inheritance would result in tables only containing an id column. ### [DDC-1180] Indexed Associations: foreign key (association) cannot be used as indexBy field Created: 29/May/11 Updated: 02/Mar/13 Status: Open Project: Doctrine 2 - ORM Component/s: Mapping Drivers Affects Version/s: 2.1 Fix Version/s: None Security Level: All  Type: Improvement Priority: Major Reporter: Petr Sobotka Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 3 Labels: None Environment: Using Doctrine ORM 2.1.0BETA1  Description  I am trying to index a collection by its entity's column which is also a foreign key (association). It seems to me that it is not possible at the moment. For example: /** * @Entity */ class Hotel { //$id column and other stuff /** * @oneToMany(targetEntity="Booking", mappedBy="hotel", indexBy="room") * @var Booking[] */ private $bookings; } /** * @Entity */ class Booking { /** * @var Hotel * * @Id * @ManyToOne(targetEntity="Hotel", inversedBy="bookings") * @JoinColumns({ * @JoinColumn(name="hotel_id", referencedColumnName="id") * }) */ private$hotel; /** * @var Room * * @Id * @ManyToOne(targetEntity="Room") * @JoinColumns({ * @JoinColumn(name="room_id", referencedColumnName="id") * }) */ private $room; }  Only possible workaround I found is to define another (plain) entity's property mapped to the same table column and index by it: /** * @Entity */ class Hotel { //$id column and other stuff /** * @oneToMany(targetEntity="Booking", mappedBy="hotel", indexBy="roomId") * @var Booking[] */ private $bookings; } /** * @Entity */ class Booking { // ... /** * @var Room * * @Id * @ManyToOne(targetEntity="Room") * @JoinColumns({ * @JoinColumn(name="room_id", referencedColumnName="id") * }) */ private$room; /** * @var integer $roomId * * @Column(name="room_id", type="integer", nullable=false) */ private$roomId; }  Wouldn't it be easy to support it?

 Comment by Benjamin Eberlei [ 05/Jun/11 ] It is not so easy to implement from the first gimplse and it is not a bug but an improvement/feature request. Comment by Benjamin Morel [ 02/Mar/13 ]

### [DDC-2337] Allow an entity to use its own persister to take advantage of DB level features if necessary Created: 06/Mar/13  Updated: 06/Mar/13

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

 Type: New Feature Priority: Major Reporter: Nathanael Noblet Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: None

 Attachments: persister.patch

 Description
 I have a situation where I wanted a single table to use INSERT DELAYED. Its an audit log table where I expect each http request to generate many inserts for. In an effort to not over tax the system I implemented a custom Entity Persister so that it would work. This obviously doesn't work with all mapping drivers. However if this is a feature that you think is worth integrating I will fork it on github and complete the implementation alongside any changes/improvements requested...

### [DDC-2354] [GH-617] Wrong UnitOfWork::computeChangeSet() Created: 16/Mar/13  Updated: 16/Mar/13

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

 Description
 This issue is created automatically through a Github pull request on behalf of fchris82: Message: Sometimes some fields are Proxy when compute "changeSet". If it is Proxy, some listeners - example Gedmo sortable listener - belive the value has changed and this leads to chaos. I check the $actualValue, if it is Proxy, the value didn't change. ### [DDC-2351] Entity Listener vs. Event Listener Created: 15/Mar/13 Updated: 15/Mar/13 Status: Open Project: Doctrine 2 - ORM Component/s: None Affects Version/s: Git Master Fix Version/s: None Security Level: All  Type: Improvement Priority: Major Reporter: Fabian Spillner Assignee: Fabio B. Silva Resolution: Unresolved Votes: 0 Labels: None  Description  Entity Listener and Event Listener don't get same events. An example is the onFlush event, which Entity Listener doesn't get. Why are both listeners receiving different events and not same events? For consistency I'd like to see that both get same events - if I understand the purpose of Entity Listener correctly: it should be an alternative to Event Listener with same functionality but is bound to an entity.  Comments  Comment by Benjamin Eberlei [ 15/Mar/13 ] onFlush and postFlush should be propagated to entity listeners as well ### [DDC-2352] [GH-615] Update SqlWalker.php Created: 15/Mar/13 Updated: 15/Mar/13 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  Description  This issue is created automatically through a Github pull request on behalf of mikemeier: Message: Always be sure that only a-z characters are used for table alias, otherwise use generic "t" for "table" ### [DDC-2363] Duplicated record with orphanRemoval and proxy Created: 22/Mar/13 Updated: 22/Mar/13 Status: Open 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  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. ### [DDC-2364] [GH-625] [DDC-2363] Duplicated record with orphanRemoval and proxy Created: 22/Mar/13 Updated: 22/Mar/13 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  Description  This issue is created automatically through a Github pull request on behalf of mmenozzi: Message: ### [DDC-2119] Problem with inheritance type: INHERITANCE_TYPE_NONE and INHERITANCE_TYPE_TABLE_PER_CLASS Created: 03/Nov/12 Updated: 08/Apr/13 Status: Open Project: Doctrine 2 - ORM Component/s: DQL, Tools Affects Version/s: 2.1 Fix Version/s: None  Type: Bug Priority: Major Reporter: SergSW Assignee: Benjamin Eberlei Resolution: Unresolved Votes: 0 Labels: dql, schematool  Attachments: dump.sql SSWTestBundle.rar  Description  I tried to create inheritance entities with save policy table per class. Simple fileds was created normally, but a field with ManyToOne type was lost. I had found a solution. In Doctrine\ORM\Tools\SchemaTool ... private function _gatherRelationsSql($class, $table,$schema) { foreach ($class->associationMappings as$fieldName => $mapping) { // if (isset($mapping['inherited'])) { // - old version /** * SSW * It's the solution */ if (isset($mapping['inherited']) && !$class->isInheritanceTypeNone() && !$class->isInheritanceTypeTablePerClass() ) { continue; }$foreignClass = $this->_em->getClassMetadata($mapping['targetEntity']); ...  But it was enough. In DQL query a simple query was made wrong. I had found a solution again. In Doctrine\ORM\Query\SqlWalker ... public function walkSelectExpression($selectExpression) ... // original => if (isset($mapping['inherited'])){ // It's the solution if (isset($mapping['inherited']) && !$class->isInheritanceTypeNone() && !$class->isInheritanceTypeTablePerClass()) {$tableName = $this->_em->getClassMetadata($mapping['inherited'])->table['name']; } else { $tableName =$class->table['name']; } ...  This problems are topical for inheritance type: INHERITANCE_TYPE_NONE and INHERITANCE_TYPE_TABLE_PER_CLASS. I don't know, may be my solutions are wrong. But some programmers want to correctly work with INHERITANCE_TYPE_TABLE_PER_CLASS. Sorry for my english.

 Comment by Fabio B. Silva [ 05/Nov/12 ] Hi SergSW Could you try to write a failing test case ? Thanks Comment by SergSW [ 06/Nov/12 ] SSW/TestBundle with the problem Comment by SergSW [ 07/Nov/12 ] I install the Symfony v2.0.18. and made small TestBundle. I made schema database, by CLI "console doctrine:schema:update --force" Result: Database schema updated successfully! But I saw that I lost a field 'user_id' in a table 'AttachTree' (see Attach) Comment by SergSW [ 07/Nov/12 ] MySQL dump Comment by Benjamin Eberlei [ 12/Nov/12 ] Adjusted example formatting, don't apologize for your English, thanks for the report! Comment by Benjamin Eberlei [ 24/Dec/12 ] What version of 2.1 are you using? We don't actually support 2.1 anymore. Inheritance has always worked as used in hundrets of unit-tests, this changes look quite major a bug to have been missed before. I can't really explain whats happening here. Comment by Marco Pivetta [ 23/Jan/13 ] SergSW news?

### [DDC-2401] INDEX BY not working on multiple columns Created: 16/Apr/13  Updated: 18/Apr/13

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

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

 Attachments: Testcase.zip

 Description
 According to the docs on this page: http://docs.doctrine-project.org/en/latest/reference/dql-doctrine-query-language.html#using-index-by The following "multi-dimensional index" should be perfectly possible, with a default hydration mode: SELECT b as business, p as product FROM Businesses b INDEX BY b.id JOIN Products p WITH b.id = p.businessid INDEX BY p.id However, b.id is completely ignored (it is a numeric primary key). I tried to go further, giving 2 products a matching barcode and indexing by barcode and then a (unique, numeric) productid. Only the barcode worked as a key and only one of the products with a matching barcode was selected. I used this query to test: SELECT p FROM Products p INDEX BY p.barcode JOIN p.businessid b INDEX BY p.id I also flagged the docs, because I don't think a userid should/could be starting from 0.

 Comment by Fabio B. Silva [ 18/Apr/13 ] Hi Quintenvk Could you please try to write a failing test case ? Thanks Comment by Quintenvk [ 18/Apr/13 ] I added a testcase. Please note that the database settings are to be configured in Core/simplys/simplys.php, and that the dump is in dummy.sql. Apart from that all should run well immediately. Comment by Quintenvk [ 18/Apr/13 ] Fabio, Please check the zip I just attached. I hope this helps you in finding the problem. Thanks, Quinten Comment by Fabio B. Silva [ 18/Apr/13 ] Thanks Quintenvk, SELECT p.barcode, p.id, p.name FROM \core\Simplys\Entity\Products p INDEX BY p.barcode JOIN p.businessid b INDEX BY p.id In this DQL you are trying to index by scalar values, I think we does not support that, and a single dimensional array is the expected result in this case. Also the INDEX BY documentations seems wrong to me. The given DQL :  SELECT u.id, u.status, upper(u.name) nameUpper FROM User u INDEX BY u.idJOIN u.phonenumbers p INDEX BY p.phonenumber  Show the following result : array 0 => array 1 => object(stdClass)[299] public '__CLASS__' => string 'Doctrine\Tests\Models\CMS\CmsUser' (length=33) public 'id' => int 1 .. 'nameUpper' => string 'ROMANB' (length=6) 1 => array 2 => object(stdClass)[298] public '__CLASS__' => string 'Doctrine\Tests\Models\CMS\CmsUser' (length=33) public 'id' => int 2 ... 'nameUpper' => string 'JWAGE' (length=5)  Which IMHO represents another DQL, something like :  SELECT u, p , upper(u.name) nameUpper FROM User u INDEX BY u.id JOIN u.phonenumbers p INDEX BY p.phonenumber` Comment by Quintenvk [ 18/Apr/13 ] Thanks for your reply Fabio. Do you think there could be alternatives (apart from a foreach-loop) to achieve the expected result? Thanks, Quinten Comment by