mirror of
https://github.com/doctrine/orm.git
synced 2026-04-29 09:23:20 +02:00
Add symfony expression syntax to collection relations annotation #6142
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 @rpodwika on GitHub (Dec 20, 2018).
Originally assigned to: @Ocramius on GitHub.
Feature Request
Summary
To use indexBy with foreign key you need to add the key as class property which is considered to be a bad practice.
Imagine situation when you have class Foo that hass class Related with relation type one to many
@ORM\OneToMany(targetEntity="Foo", mappedBy="foo", indexBy="relatedId")I would like to use doctrine expression or be able to index by a foreign key.
@ORM\OneToMany(targetEntity="Foo", mappedBy="foo", indexBy="$related->getId()")@SenseException commented on GitHub (Dec 21, 2018):
Your current entity relation is: One
Relatedentity can have one or moreFooentities and you want the collection ofFoouse the id ofRelated?indexByis supposed have a unique key.indexByis supposed to get a property with a unique value like in this example:Can you please elaborate your use case?
@Ocramius commented on GitHub (Dec 21, 2018):
This:
Is absolutely too complex, and an edge case too.
Closing as
won't fix, since this logic is trivially implemented in userland with collection operations, without having to introduce massive complexity, pseudo-code in mappings, nor potential code parsing and evaluation facilities that are not worth building unless they are an evident game changer.