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

[10.x] Model::preventAccessingMissingAttributes() raises exception for castable attributes that were not retrieved #49470

Conversation

cosmastech
Copy link
Contributor

@cosmastech cosmastech commented Dec 22, 2023

To resolve #49434

Previously, a castable attribute that was not retrieved from the DB would not raise this exception. By checking that the attribute was retrieved before attempting to cast the attribute, the preventAccessingMissingAttributes works intuitively in such a case.

@cosmastech cosmastech changed the title [10.x] Model::preventAccessingMissingAttributes() raises exception when retrieving attribute that has a cast [10.x] Model::preventAccessingMissingAttributes() raises exception for castable attributes that were not retrieved Dec 22, 2023
@cosmastech cosmastech marked this pull request as ready for review December 22, 2023 12:42
@taylorotwell
Copy link
Member

This would break a lot of use cases where cast objects are "virtual" - think about an address value object that is resolved from multiple attributes. It never actually exists in the attributes array itself.

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

Successfully merging this pull request may close these issues.

Model::preventAccessingMissingAttributes() doesn't fire when needed if cast is defined
2 participants