API Platform version(s) affected: 2.5.4
Description
When trying to sort on a field of an @ORM\Embedded object, it doesn't work if I use the nulls_comparison of the OrderFilter.
Here is an example (for the full code, see the provided reproducer below):
/**
* @ApiResource()
* @ORM\Entity()
*
* @ApiFilter(OrderFilter::class, properties = {
* "bar.luckyNumber" : { "nulls_comparison" : OrderFilter::NULLS_SMALLEST },
* "bar.secondLuckyNumber"
* })
*/
class Foo
Here, if bar is Embedded, the request to /foos?order[bar.luckyNumber]=asc will fail with the error
[Syntax Error] line 0, col 80: Error: Expected Doctrine\ORM\Query\Lexer::T_FROM, got '.'
However, the request to /foos?order[bar.secondLuckyNumber]=asc will work as expected because it doesn't use the nulls_comparison option. It will use the default behavior of Postgres which is NULL considered as largest which is not what I want here.
How to reproduce
For simplicity sake, I've created a reproducer repository which uses the api-platform/api-platform distribution.
Here it is : https://github.com/t-richard/order-filter-reproducer
I've also provided Doctrine migrations and Doctrine fixtures in the reproducer.
Once the project is up and the fixtures loaded, you can make an HTTP call to
Possible Solution
I've not managed to find where the problem comes from, but I may be able to provide a PR if you guys can help me out to identify the problem.
Let me know if I can be of any help !
API Platform version(s) affected: 2.5.4
Description
When trying to sort on a field of an
@ORM\Embeddedobject, it doesn't work if I use thenulls_comparisonof theOrderFilter.Here is an example (for the full code, see the provided reproducer below):
Here, if
baris Embedded, the request to/foos?order[bar.luckyNumber]=ascwill fail with the errorHowever, the request to
/foos?order[bar.secondLuckyNumber]=ascwill work as expected because it doesn't use thenulls_comparisonoption. It will use the default behavior of Postgres which isNULLconsidered as largest which is not what I want here.How to reproduce
For simplicity sake, I've created a reproducer repository which uses the
api-platform/api-platformdistribution.Here it is : https://github.com/t-richard/order-filter-reproducer
I've also provided Doctrine migrations and Doctrine fixtures in the reproducer.
Once the project is up and the fixtures loaded, you can make an HTTP call to
Possible Solution
I've not managed to find where the problem comes from, but I may be able to provide a PR if you guys can help me out to identify the problem.
Let me know if I can be of any help !