Skip to content

orderBy fails on MYSQL 5.7.9 when using Paginator #672

@jakenoble

Description

@jakenoble

Full details here http://stackoverflow.com/questions/33900219/doctrine2-symfony2-paginator-fails-with-orderby

Essentially this simple code fails

     $builder = $this->createQueryBuilder("s");
     $builder->addOrderBy("s.name", "ASC");
     $pagi = new Paginator($builder->getQuery(), true);
     $data = $pagi->getIterator()->getArrayCopy();

With the following error

SQLSTATE[HY000]: General error: 3065 Expression #1 of ORDER BY clause is not in SELECT list, references column 'dctrn_result.name_5' which is not in SELECT list; this is incompatible with DISTINCT") in AppBundle:Schools/Search:results_list.html.twig at line 33.

The name column exists, and renaming the reference from s.name to name fails too.

Removing the addOrderBy results in a successful fetch too. So the issue is certainly related to using addOrderBy with a Doctrine2 Paginator.

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