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

DDC-3603: Readonly columns #4427

Closed
doctrinebot opened this issue Mar 6, 2015 · 8 comments
Closed

DDC-3603: Readonly columns #4427

doctrinebot opened this issue Mar 6, 2015 · 8 comments

Comments

@doctrinebot
Copy link

Jira issue originally created by user sparrowek:

Sometimes I have a column that is calculated (or have a default value) at the database side. When inserting a new record doctrine issues NULL into such a column that causes problems on some DBMS. I would like to annotate such columns as readonly so that doctrine would skip them in INSERT and UPDATE clauses but still fetch them in SELECT clauses.

@Hikariii
Copy link

Issued a PR for exactly this: #5728

@Hikariii
Copy link

@beberlei This becomes more urgent as more people start using mysql 5.7 and generated columns.
See #5728 for more details on why this is important.

@Ocramius
Copy link
Member

Described my thoughts about this feature in #5728

@dbu
Copy link
Member

dbu commented Feb 26, 2019

as #5728 has been closed, should this be closed too?

if you write your query in dbal, you can completely hide columns from ORM with a schema listener. the column won't be mapped on the entity however, and is not available for DQL / ORM query builder.

@0xPaul
Copy link

0xPaul commented Dec 20, 2021

This should not be closed because, as far as I can tell, there still isn't support for read-only generated columns within the ORM.

@garak
Copy link

garak commented Feb 11, 2022

Readonly on primary keys is not working for me. As soon as I try to hydrate the object, the UnitOfWork tries to call setValue method on the property, resulting in an exception ("Attempting to change readonly property My\Entity\Foo::$id.")

@derrabus
Copy link
Member

@garak The ticket you are commenting on has nothing to with the PHP language feature readonly. Please file a bug for your issue.

@beberlei
Copy link
Member

This was implemented in 2.11 as virtual and generated columns

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

No branches or pull requests

8 participants