Description
If you have some ORM entity with ManyToOne relation, no way to clear this relations. Or I can't find this possibility.
How to reproduce
Add entity like this:
#[ORM\Entity(repositoryClass: OrderRepository::class)]
#[ORM\Table('orders')]
class Order
{
# ..... other properties is here
#[ORM\ManyToOne(targetEntity: ...)]
#[ORM\JoinColumn(nullable: true)]
#[Groups(...)]
protected ?TradingContractInterface $tradingContract = null;
public function getTradingContract(): ?TradingContractInterface
{
return $this->tradingContract;
}
public function setTradingContract(?TradingContractInterface $tradingContract = null): static
{
$this->tradingContract = $tradingContract;
return $this;
}
}
Publish REST methods with API Platform (in my case I did it with yaml):
3. Try to update entity with PATCH or PUT /admin/orders/{id} with json like:
```json
{
# ...other properties
tradingContract: null
}
Expected behaviour: PATCH and PUT methods should clear current value of property tradingContract end return json without tradingContract property (due to skip_null_values option with value true passed to normaliser).
Actual behaviour: Property did not set to null, and the response includes property tradingContract with old data.
Possible Solution
I think you should change current logic of default denormaliser or add some config options to switch this behaviour.
API Platform version(s) affected: 3.3.2
Description
If you have some ORM entity with ManyToOne relation, no way to clear this relations. Or I can't find this possibility.
How to reproduce
Add entity like this:
Publish REST methods with API Platform (in my case I did it with yaml):
Expected behaviour: PATCH and PUT methods should clear current value of property tradingContract end return json without tradingContract property (due to skip_null_values option with value true passed to normaliser).
Actual behaviour: Property did not set to null, and the response includes property tradingContract with old data.
Possible Solution
I think you should change current logic of default denormaliser or add some config options to switch this behaviour.