Closed bettinz closed 3 years ago
same issue here:
namespace App\Document;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
use ApiPlatform\Core\Bridge\Doctrine\MongoDbOdm\Filter\DateFilter;
use ApiPlatform\Core\Bridge\Doctrine\MongoDbOdm\Filter\SearchFilter;
use App\Document\User;
/**
* Class Event
* @package App\Entity
*
* @ApiResource(
* attributes={
* "doctrine_mongodb"={
* "execute_options"={
* "allowDiskUse"=true
* }
* },
* "order"={"dateTime": "DESC"},
* "pagination_client_items_per_page"=true
* },
* collectionOperations={
* "get" = {
* "openapi_context"={
* "summary" = "Retrieve the list of all Events",
* },
* }
* },
* itemOperations={
* "get" = {
* "openapi_context"={
* "summary" = "Retrieve the informations about a single Event",
* },
* }
* }
* )
*
* @ApiFilter(DateFilter::class, properties={"dateTime"})
* @ApiFilter(SearchFilter::class , properties={"client": "exact", "type": "exact", "code": "exact", "subCode": "exact", "title": "partial", "description": "partial" ,"user.email": "exact", "body": "partial"})
*
* @ODM\Document(collection="event")
*/
class Event
{
const TYPE_INFO = 'info';
const TYPE_ERROR = 'error';
/**
* @ODM\Id(name="_id", type="string")
*/
private $id;
/**
* @ODM\Field
*/
private $type;
/**
* @ODM\Field
*/
private $code;
/**
* @ODM\Field
*/
private $subCode;
/**
* @ODM\Field(type="collection")
*/
private $body;
/**
* @ODM\Field
*/
private $title;
/**
* @ODM\Field
*/
private $description;
/**
*
* @ODM\EmbedOne(targetDocument=User::class)
*/
private $user;
/**
* @ODM\Field(type="date")
*/
private $dateTime;
/**
* @var string
* @ODM\Field()
*/
private $client;
/**
* @ODM\Field
*/
private $url;
....
<?php
namespace App\Document;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
/**
* @ODM\EmbeddedDocument
*
*/
class User
{
/** @ODM\Field(type="string") */
private $firstName;
/** @ODM\Field(type="string") */
private $lastName;
/** @ODM\Field(type="string") */
private $email;
/** @ODM\Field(type="string") */
private $city;
/** @ODM\Field(type="string") */
private $address;
/** @ODM\Field(type="string") */
private $uuid;
/** @ODM\Field(type="string") */
private $company;
/** @ODM\Field(type="string") */
private $companyName;
/** @ODM\Field(type="string") */
private $phone;
....
from 2.6.4 user.email
filter is not working!
@alanpoulain are you sure that #4218 is related with this?
This one is probably the fix: https://github.com/api-platform/core/pull/4221.
@alanpoulain hmm... I'm not sure, the fix only does fix the required filter validation, but not the fact that the doctrine filter does work after that.
It might be related to a similar change in 2.6 though?
@jdeniau @alanpoulain any news?
@simocheccoli #4221 has been merged, can you try on the 2.6
branch if it did fix your issue ?
@jdeniau @alanpoulain we can confirm that 2.6
branch fix this issue!
Thank you @jdeniau @alanpoulain and @simocheccoli for the help 😎
@jdeniau , @alanpoulain it seems that only version 5.* of mongodb is working... with mongo 4.2.3 this problem persists
Hello, I've updated Api-Platform to version 2.6.4 and since 2.6.x filter on nested properties doesn't work with doctrine and mongodb. I've a user entity with email property and events with user.email as filter. Other filters work as expected:
user.email is ignored type is working
Can you help me? Thanks.