The classes below should describe the issue. We are using uuids in API request and internal it uses ids.
useApiPlatform\Metadata\ApiFilter;
useApiPlatform\Metadata\ApiProperty;
useApiPlatform\Metadata\ApiResource;
useApiPlatform\Metadata\Get;
useApiPlatform\Metadata\GetCollection;
useApiPlatform\Doctrine\Orm\Filter\SearchFilter;
useDoctrine\Common\Collections\ArrayCollection;
useDoctrine\ORM\MappingasORM;
useSymfony\Component\Uid\Uuid;
#[ApiResource(
operations: [
newGetCollection(),
newGet(),
],
)]
#[ApiFilter(SearchFilter::class, properties: ['groups' => 'exact'])]
#[ORM\Entity]
class User
{
#[ApiProperty(readable: false, writable: false, identifier: false)]
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
privateint$id;
#[ApiProperty(writable: false, identifier: true)]
#[ORM\Column(type: 'uuid', unique: true)]
privateUuid$uuid;
#[ORM\ManyToMany(targetEntity: Group::class, inversedBy: 'users')]
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id')]
#[ORM\InverseJoinColumn(name: 'group_id', referencedColumnName: 'id')]
privateCollection$groups;
publicfunction__construct()
{
$this->uuid = Uuid::v4();
$this->groups = newArrayCollection();
}
}
---
useApiPlatform\Metadata\ApiProperty;
useApiPlatform\Metadata\ApiResource;
useApiPlatform\Metadata\Get;
useApiPlatform\Metadata\GetCollection;
useSymfony\Component\Uid\Uuid;
#[ApiResource(
operations: [
newGetCollection(),
newGet(),
],
)]
#[ORM\Entity]
class Group
{
#[ApiProperty(readable: false, writable: false, identifier: false)]
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
privateint$id;
#[ApiProperty(writable: false, identifier: true)]
#[ORM\Column(type: 'uuid', unique: true)]
privateUuid$uuid;
publicfunction__construct()
{
$this->uuid = Uuid::v4();
}
}The request we execute is "/api/v2/users?groups=/api/v2/groups/61817181-0ecc-42fb-a6e7-d97f2ddcb344"
API Platform version(s) affected: 3.1.13
Description
This PR (#5623) breaks our test suite because no where query is added to doctrine.
How to reproduce
The classes below should describe the issue. We are using uuids in API request and internal it uses ids.
The request we execute is "/api/v2/users?groups=/api/v2/groups/61817181-0ecc-42fb-a6e7-d97f2ddcb344"
Line https://github.com/api-platform/core/blob/main/src/Doctrine/Common/Filter/SearchFilterTrait.php#L133 now returns the uuid "61817181-0ecc-42fb-a6e7-d97f2ddcb344" and before we get the internal id value from https://github.com/api-platform/core/blob/main/src/Doctrine/Common/Filter/SearchFilterTrait.php#L128
This line https://github.com/api-platform/core/blob/main/src/Doctrine/Orm/Filter/SearchFilter.php#L225 returns the id field and will now return in this line https://github.com/api-platform/core/blob/main/src/Doctrine/Orm/Filter/SearchFilter.php#L233. So the where query (https://github.com/api-platform/core/blob/main/src/Doctrine/Orm/Filter/SearchFilter.php#L243) is not added anymore.
Possible Solution
Additional Context