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

@Column yields errors when using the 'generated' option. #11559

Open
whataboutpereira opened this issue Jul 28, 2024 · 0 comments
Open

@Column yields errors when using the 'generated' option. #11559

whataboutpereira opened this issue Jul 28, 2024 · 0 comments

Comments

@whataboutpereira
Copy link

Bug Report

Q A
BC Break no
Version 3.2.1

Summary

Using the Column option generated: 'NEVER' yields an error:

Typed property Doctrine\ORM\Mapping\FieldMapping::$generated must not be accessed before initialization

Current behavior

Using the Column option generated: 'NEVER' yields an error and generated: 'INSERT' works unexpectedly.

How to reproduce

Using a database trigger to update a field defined as such:

    #[ORM\Column(
        name: 'UnreadComments',
        options: ['unsigned' => true, 'default' => 0],
        insertable: false,
        updatable: false,
    )]

This yields an error from phpstan (I know I can silence it):

Property App\Entity\User::$unreadComments is never written, only read.

This made me look at the 'generated' option and when adding generated: 'NEVER' to the column options I get the following error:

Typed property Doctrine\ORM\Mapping\FieldMapping::$generated must not be accessed before initialization

When adding generated: 'INSERT' to the column options, phpstan will be silent, but a SELECT is done after UPDATE to the entity.

Expected behavior

generated: 'NEVER' should not yield an error and should not refresh field after update or insert.
generated: 'INSERT' should refresh the field after insert, but not after update?

Documentation says generated: An enum with the possible values ALWAYS, INSERT, NEVER. Is used after an INSERT or UPDATE statement to determine if the database generated this value and it needs to be fetched using a SELECT statement.

What is the default?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant