Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DoctrineBridge] Make EntityValueResolver return null if a composite ID value is null #57625

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

Merged
merged 1 commit into from
Jul 28, 2024

Conversation

MatTheCat
Copy link
Contributor

@MatTheCat MatTheCat commented Jul 2, 2024

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues N/A
License MIT

My use-case is the upsert of an entity identified by two values. I have an update route with these two values as route parameters, and a create route with only one. In that case the second value is null but the EntityValueResolver will still call the repository’s find method, resulting in a MissingIdentifierField exception:

The identifier [VALUE] is missing for a query of [ENTITY]

This PR makes the EntityValueResolver return null in this case, like when a scalar ID is null.

@carsonbot carsonbot added this to the 6.4 milestone Jul 2, 2024
@MatTheCat MatTheCat force-pushed the entity_resolver_null_in_id_array branch from 6169fea to dccc78d Compare July 5, 2024 09:57
@MatTheCat MatTheCat changed the title [DoctrineBridge] Prevent EntityValueResolver to crash if an ID part is null [DoctrineBridge] Make EntityValueResolver return null if an ID part is null Jul 5, 2024
@MatTheCat MatTheCat force-pushed the entity_resolver_null_in_id_array branch from dccc78d to e88c19f Compare July 8, 2024 14:33
@MatTheCat MatTheCat changed the title [DoctrineBridge] Make EntityValueResolver return null if an ID part is null [DoctrineBridge] Make EntityValueResolver return null if a composite ID value is null Jul 8, 2024
@MatTheCat MatTheCat force-pushed the entity_resolver_null_in_id_array branch from e88c19f to 4dd870a Compare July 15, 2024 12:37
@MatTheCat MatTheCat force-pushed the entity_resolver_null_in_id_array branch from 4dd870a to a687f83 Compare July 15, 2024 14:51
@MatTheCat MatTheCat force-pushed the entity_resolver_null_in_id_array branch from a687f83 to 87f1884 Compare July 17, 2024 11:35
@xabbuh
Copy link
Member

xabbuh commented Jul 28, 2024

Thank you @MatTheCat.

@xabbuh xabbuh merged commit 5cffe22 into symfony:6.4 Jul 28, 2024
10 checks passed
@MatTheCat MatTheCat deleted the entity_resolver_null_in_id_array branch July 28, 2024 12:40
This was referenced Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants