-
-
Notifications
You must be signed in to change notification settings - Fork 946
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
UniqueEntity not fully working on PUT #2682
Comments
add entityClass #[UniqueEntity(fields: ['name'], errorPath: 'name', ignoreNull: false, entityClass: self::class)] |
@SakhriHoussem The issue still persists despite implementing this solution. if i use :
Everything works as expected, but I'm unsure if this is a smart idea. Thoughts? |
Has anyone else experienced this issue? I would expect this to be a basic function. It seems comparable to updating a user's name when there's a unique constraint on the email address. Am I doing something wrong? |
I have same problem. It seems that the entity does not check the current value before updating PS I figured it out, it turns out I had records in the database with the same unique field value. |
API Platform version(s) affected: 3.2.18
Description
If you have a unique property in your entity it is impossible to update other properties with PUT
How to reproduce
Example entity:
It is impossible to update the description of this created entity as it consistently returns the following response:
Additional Context
It seems that the entity, which is being updated, is not fully loaded during validation. In the UniqueEntityValidator, there is this code to exclude its own
but $entity is not holding the id of the entity that needs updating.
Edit:
In the screenshot, it can be seen that I'm attempting to update the entity with an ID of "1".
Interestingly, the cause of failure is reported to be the same entity with an ID of "1".
If I'm not using the intended way, please let me know the correct method.
The text was updated successfully, but these errors were encountered: