-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Readonly column property for generated/virtual columns #5728
Conversation
Fixes #4427 |
As more people are moving towards mysql 5.7 this will become more of an issue. |
This seems to support an edge-case scenario that is DB-specific. Any reason why you can't simply skip mapping those fields? In addition to that, userland object implementations may still overwrite those field values, leading to out-of-sync db and object model. In addition to that a full entity refresh should be forced if one of those fields is computed. I think the resolution for this issue is as simple as "don't map it", which will lead the ORM to completely ignore the field anyway. Tossing in my 👎 for now, but I hope you understand why this is my opinion on the feature. |
I'm planning to remove "readOnly" support in ORM 3.0 and implement a decoupled support through: "insertable" and "updatable" at both Entity and Column level. Adding something that will be immediately deprecated after is a no-go to me. |
Closing this as per @guilhermeblanco's comment. |
Is there any solution of the problem? I have some issues with a column generated from the “Sequence” in my database (Postgresql) |
A similar solution based on this PR, but not with
Additional conditions: Should throw exception for UPDATE statements attempting to update this field/column. Could be combined directly by adding One question would be, if an update or insert is done, then the persister must probably fetch the value of the columns from the database, because they are virtual and might be updated. Example: Auto Increment non ID columns, or timestamps updated on write, trigger based columns. |
Where can i find the similar solution that you was talking to merge? |
Defines whether a column is included in an SQL INSERT and/or UPDATE statement. Throws an exception for UPDATE statements attempting to update this field/column. doctrine#5728
Defines whether a column is included in an SQL INSERT and/or UPDATE statement. Throws an exception for UPDATE statements attempting to update this field/column. doctrine#5728
Added documentation. doctrine#5728
Defines whether a column is included in an SQL INSERT and/or UPDATE statement. Throws an exception for UPDATE statements attempting to update this field/column. doctrine#5728
Added documentation. doctrine#5728
Defines whether a column is included in an SQL INSERT and/or UPDATE statement. Throws an exception for UPDATE statements attempting to update this field/column. doctrine#5728
Added documentation. doctrine#5728
Refactoring reg. change request - Using more ORM idomatic style. - Inverting 'insertable' and 'updateable' reg. optimization of the ClassMetadata cache. doctrine#5728
Defines whether a column is included in an SQL INSERT and/or UPDATE statement. Throws an exception for UPDATE statements attempting to update this field/column. doctrine#5728
Added documentation. doctrine#5728
Refactoring reg. change request - Using more ORM idomatic style. - Inverting 'insertable' and 'updateable' reg. optimization of the ClassMetadata cache. doctrine#5728
Refactoring reg. change request - Fetch not insertable / updateable columns after an insert / update and set them on the entity. doctrine#5728
Refactoring reg. change request - Fetch not insertable / updateable columns after an insert / update and set them on the entity. doctrine#5728
Defines whether a column is included in an SQL INSERT and/or UPDATE statement. Throws an exception for UPDATE statements attempting to update this field/column. Closes doctrine#5728
Defines whether a column is included in an SQL INSERT and/or UPDATE statement. Throws an exception for UPDATE statements attempting to update this field/column. Closes doctrine#5728
* Generated/Virtual Columns: Insertable / Updateable Defines whether a column is included in an SQL INSERT and/or UPDATE statement. Throws an exception for UPDATE statements attempting to update this field/column. Closes #5728 * Apply suggestions from code review Co-authored-by: Grégoire Paris <[email protected]> * Add example for virtual column usage in attributes to docs. Co-authored-by: Benjamin Eberlei <[email protected]> Co-authored-by: Grégoire Paris <[email protected]>
MySQL and MariaDB both support virtual/computed/generated columns.
This is a column in a table that has its value automatically calculated using a deterministic expression, in particular from the values of other fields in the table.
These columns are queried like any other column, but its values cannot be inserted or updated.
To use these columns in entities and DQL, Doctrine must find a way to define them, but not include them in updates and inserts. This PR accomplishes just that.
More info on these columns: