mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-250: ArrayCollection Key Column @indexBy #308
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Jan 12, 2010).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user mridgway:
To be honest I feel like I saw this mentioned somewhere, but after looking around I couldn't find it, so I'll just post this anyway.
I'd like the ability to set a property as the associative key on ArrayCollections. This functionality could probably be done in a PostLoad by iterating over the objects, but it seems like ArrayCollection should be able to handle this functionality already, it's just a matter of modifying the mapper/parser.
Example:
If you were able to specify an ArrayCollection key column then you would be able to have functions like getParam without having to loop over the objects in the collection. Something like:
none @OneToMany(targetEntity="Param", mappedBy="object", collectionKey="name")@doctrinebot commented on GitHub (Jan 12, 2010):
@doctrinebot commented on GitHub (Apr 19, 2010):
Comment created by marijn:
As much as I would like this I doubt it is -possible- feasible. Imagine the
namecolumn of yourParamobject not being unique for you your linkedObject..? How could theArrayCollectionknow which instance to add to the collection and which one not?@doctrinebot commented on GitHub (Apr 19, 2010):
Comment created by mridgway:
You are absolutely correct. There is no way to ensure the uniqueness of the collection elements. This is something that would have to be ensured in the domain model and shouldn't have anything to do with Doctrine.
It will certainly work to loop through the collection on PostLoad (once DDC-54 is implemented). For now, I just set the keys the first time I call getParam().
I suppose I should close this (I forgot it was still open).
@doctrinebot commented on GitHub (Oct 6, 2010):
Comment created by mridgway:
I just noticed that DQL has an INDEX BY keyword to be able to do this during a DQL query. Is this something that could then be possible to set in a oneToMany or manyToMany? It seems like most of the groundwork for being able to do this is already done.
@doctrinebot commented on GitHub (Dec 24, 2010):
Comment created by @beberlei:
Example code:
In this case @IndexBy uses the Translation::$language as key for the collection.
@doctrinebot commented on GitHub (Dec 24, 2010):
Comment created by @beberlei:
Schedule for 2.1
@doctrinebot commented on GitHub (Feb 5, 2011):
Comment created by @beberlei:
This is now in master
7390030854Syntax is:
@doctrinebot commented on GitHub (Feb 5, 2011):
Issue was closed with resolution "Fixed"
@doctrinebot commented on GitHub (Oct 11, 2012):
Comment created by @beberlei:
A related Github Pull-Request [GH-470] was opened
https://github.com/doctrine/doctrine2/pull/470
@doctrinebot commented on GitHub (Dec 29, 2013):
Comment created by @doctrinebot:
A related Github Pull-Request [GH-470] was closed:
https://github.com/doctrine/dbal/pull/470
@doctrinebot commented on GitHub (Jan 12, 2015):
Comment created by @doctrinebot:
A related Github Pull-Request [GH-470] was assigned:
https://github.com/doctrine/doctrine2/pull/470
@doctrinebot commented on GitHub (Jan 13, 2015):
Comment created by @doctrinebot:
A related Github Pull-Request [GH-470] was closed:
https://github.com/doctrine/doctrine2/pull/470