Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Virtual generated column💡 #98

Open
peldax opened this issue Jun 20, 2024 · 1 comment
Open

Virtual generated column💡 #98

peldax opened this issue Jun 20, 2024 · 1 comment
Assignees
Labels
type:feature New feature.

Comments

@peldax
Copy link

peldax commented Jun 20, 2024

I have an idea!

Hi,

I would like to extend the functionality to support virtual generated columns.

In Doctrine it is possible using this explicit annotation:

#[ORM\Column(type: 'int', columnDefinition: 'INT GENERATED ALWAYS AS (IF(xyz IS TRUE, 100, 200)) VIRTUAL', generated: 'ALWAYS')]
private int $someNumber;

Possibly the freshly added GeneratedColumn attribute might be used to support the functionality?

I am open to bounty this feature.

@peldax peldax added the type:feature New feature. label Jun 20, 2024
@roxblnfk
Copy link
Member

roxblnfk commented Jun 21, 2024

Hi.
If we talk about GeneratedValue attribute, then this attribute tells ORM that field is generated on the DB side. Orm adds a generated field into returning columns when insert or update.
We can extend that attribute in the new one or extract an interface.

However I think it will be better to make a new attribute for virtual columns. For example:

#[ORM\VirtualColumn(type: 'int', expression: 'IF(xyz IS TRUE, 100, 200)', stored: true, typecast: 'int')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature New feature.
Projects
Status: No status
Development

No branches or pull requests

2 participants