Skip to content

Default order + OrderFilter produce duplicate columns in orderby #4523

@mweidt

Description

@mweidt

Hi,

I'm using ApiPlatform 2.3.5 with MS-SQL-Server as DBMS and Doctrine. In this setup I encountered the following problem.

I defined an entity with overriding the default order - e.g. @ApiResource(attributes={"order"={"foo": "ASC"}}) - and allowed an OrderFilter on the same field - e.g. @APIFilter(OrderFilter::class, properties={"foo": "ASC"}).

The request on "/entities?order[foo]=asc" produces an error with MS-SQL-Server:

A column has been specified more than once in the order by list. Columns in the order by list must be unique.

Here is the sql

... ORDER BY d0_.foo ASC, d0_.foo ASC

On MySQL the same sql is produced - but no error occures because MySQL is able to optimize the code.

In my opinion, ApiPlatform should add the default orderby only if it's not already added by OrderFilter.

Thanks for your work and your support

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions