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

Fetch EAGER ManyToOne nullable relation cannot be nulled during PUT or PATCH operation #6218

Open
ambroisemaupate opened this issue Mar 14, 2024 · 2 comments

Comments

@ambroisemaupate
Copy link
Contributor

API Platform version(s) affected: 3.2.16

Description

Entities with ORM\ManyToOne(fetch: 'EAGER') nullable relation can be setted during a PUT or PATCH with an IRI, but cannot be nulled.

If I remove fetch: 'EAGER', I can set relation to null.

How to reproduce

With EAGER fetch

#[ORM\ManyToOne(targetEntity: File::class, fetch: 'EAGER')]
#[ORM\JoinColumn(name:'image_id', nullable: true, onDelete: 'SET NULL')]
#[Groups(['block:read', 'block:write', 'webPage:single:read'])]
#[ApiProperty(description: 'File IRI reference', example: '/api/files/1ee8859e-d2fd-6bda-ae37-d9341637fbc1')]
private ?File $image = null;

image

When I inspect request in Symfony Profiler: previous_data contains an image but data too !

image

Without EAGER fetch

#[ORM\ManyToOne(targetEntity: File::class)]
#[ORM\JoinColumn(name: 'image_id', nullable: true, onDelete: 'SET NULL')]
#[Groups(['content:read', 'content:write'])]
#[ApiProperty(description: 'File IRI reference', example: '/api/files/1ee8859e-d2fd-6bda-ae37-d9341637fbc1')]
private ?File $image = null;

image

When I inspect request in Symfony Profiler: previous_data contains an image then data has null image

image

@soyuka
Copy link
Member

soyuka commented Mar 15, 2024

can you provide a reproducer ?

@ambroisemaupate
Copy link
Contributor Author

can you provide a reproducer ?

I'll make that. Male or female ? For the reproducer 🤣

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

No branches or pull requests

2 participants