Uploaded image for project: 'Doctrine 2 - ORM'
  1. Doctrine 2 - ORM
  2. DDC-2475

ORDER BY on existing column is added, not replaced


    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.3
    • Fix Version/s: 2.4
    • Component/s: DQL, ORM
    • Security Level: All
    • Labels:


      It seems that if an entity has an existing ORDER BY clause on a relation that any subsequent ORDER BYs on that field are added instead of replaced.

      For example, I have two entities: Person and Membership. Person.Memberships has the following clause specified:


      {"createDate" = "DESC"}


      I also have a repository method that uses this relationship and sets the following DQL:

      SELECT person, m
      FROM \Company\Person person
      JOIN person.memberships m
      ORDER BY m.createDate ASC

      I would expect this query to replace the existing ORDER BY with ORDER BY m.createDate ASC. Instead, it adds the ORDER BY to the existing one, which makes the end result: ORDER BY m.createDate ASC, m.createDate DESC.

      This is obviously causing an issue since you can't sort by the same column in different order. Is this behavior by design? If so, is there a way to override the existing ORDER BY setting?


        jeremylivingston Jeremy Livingston created issue -
        fabio.bat.silva Fabio B. Silva made changes -
        Field Original Value New Value
        Assignee Benjamin Eberlei [ beberlei ] Fabio B. Silva [ fabio.bat.silva ]
        fabio.bat.silva Fabio B. Silva added a comment - Fixed : https://github.com/doctrine/doctrine2/commit/753d63c2d48facdecba5d84f6ed2450024de2867
        fabio.bat.silva Fabio B. Silva made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.4 [ 10321 ]
        Resolution Fixed [ 1 ]

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={expand=changesets[0:20].revisions[0:29],reviews, query=DDC-2475}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)


          • Assignee:
            fabio.bat.silva Fabio B. Silva
            jeremylivingston Jeremy Livingston
          • Votes:
            0 Vote for this issue
            2 Start watching this issue


            • Created: