Open
Description
Feature Request
What
Going to keep this RFC short and to the point. The example speaks for itself.
Add TARGET_PROPERTY
to #[Index]
attribute.
Why
Making re-usable traits.
Now:
trait SomeCommonFields
{
#[ORM\Column(type: 'integer')]
public int $shared;
}
#[ORM\Entity]
#[ORM\Index('shared_field_idx', fields: ['shared'])] // we don't even know the fields, we have to look into the trait to find the names of the fields..
class A
{
use SomeCommonFields;
}
#[ORM\Entity]
#[ORM\Index('shared_field_idx', fields: ['shared'])]
class B
{
use SomeCommonFields;
}
Better:
trait SomeCommonFields
{
#[ORM\Index]
#[ORM\Column(type: 'integer')]
public int $shared;
}
#[ORM\Entity]
class A
{
use SomeCommonFields;
}
#[ORM\Entity]
class B
{
use SomeCommonFields;
}
How
Same way unique
already works on Column
today, it could just be included in Column
, or like the example, make the Index
attribute work on properties too. Auto generate some index name and grab the property it's attached to as the "fields".
Metadata
Metadata
Assignees
Labels
No labels