EasyCorp / EasyAdminBundle

EasyAdmin is a fast, beautiful and modern admin generator for Symfony applications.
MIT License
4.08k stars 1.03k forks source link

Paginator output walkers causing SQL error #5782

Open BriceFab opened 1 year ago

BriceFab commented 1 year ago

I am experiencing an issue when using the setPaginatorUseOutputWalkers(true) configuration option in the configureCrud method of EasyAdmin. It is causing the following SQL error:

An exception occurred while executing a query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'm0_.tree_root' in 'field list'

However, the tree_root column is present and properly registered in the database. If I set the walker to false, I do not encounter any errors. image

I am using the Soft Doctrine Tree Extension bundle in conjunction with EasyAdmin: https://github.com/doctrine-extensions/DoctrineExtensions/blob/main/doc/tree.md

Steps to reproduce:

  1. Configure the CRUD with setPaginatorUseOutputWalkers(true)
  2. Perform a query that triggers pagination

Expected behavior: No SQL error should occur when using the setPaginatorUseOutputWalkers(true) configuration.

Actual behavior: The SQL error mentioned above is thrown.

Additional information:

Please let me know if you need any further information. Thank you.

parijke commented 1 year ago

Same error here

parijke commented 1 year ago

I've created a reproducible repo. https://github.com/parijke/ea-bug

Just install, open the Teachers and try to sort on Student

image

opillion commented 1 year ago

I have the same problem, it is related to naming of the reference column. Looks like a bug, ether in the Entity Annotation or Easy Admin mapping this.

bytes-commerce commented 11 months ago

The problem seem to be existing also in a case where you have a To-Many relation (from Post to Categories) and then apply this in the Post Crud:

    public function configureCrud(Crud $crud): Crud
    {
        /** @var Crud $crud */
        $crud = parent::configureCrud($crud);
        $crud->setDefaultSort([
            'category' => 'ASC',
        ]);

        return $crud;
    }

It does not lead to a correct filtering by any means. Instead, it remains to be sorted by the ID of the given post. Attempting to do second-level filtering (i.e. category.id) result in an error:

Cannot select distinct identifiers from query with LIMIT and ORDER BY on a column from a fetch joined to-many association. Use output walkers.