Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter broken with complex join #514

Closed
fsteinbauer opened this issue Nov 12, 2018 · 2 comments
Closed

Filter broken with complex join #514

fsteinbauer opened this issue Nov 12, 2018 · 2 comments

Comments

@fsteinbauer
Copy link

When I create this query for the Paginator, I get an error message.
When I comment out the second andWhere(), it works.

Error

ymfony\Component\Debug\Exception\FatalThrowableError:
Type error: Argument 1 passed to Knp\Component\Pager\Event\Subscriber\Filtration\Doctrine\ORM\Query\WhereWalker::expressionContainsFilter() must be an instance of Doctrine\ORM\Query\AST\ConditionalExpression, instance of Doctrine\ORM\Query\AST\ConditionalPrimary given, called in /var/www/symfony/vendor/knplabs/knp-components/src/Knp/Component/Pager/Event/Subscriber/Filtration/Doctrine/ORM/Query/WhereWalker.php on line 192

  at vendor/knplabs/knp-components/src/Knp/Component/Pager/Event/Subscriber/Filtration/Doctrine/ORM/Query/WhereWalker.php:132
  at Knp\Component\Pager\Event\Subscriber\Filtration\Doctrine\ORM\Query\WhereWalker->expressionContainsFilter(object(ConditionalPrimary), array(object(LikeExpression)))
     (vendor/knplabs/knp-components/src/Knp/Component/Pager/Event/Subscriber/Filtration/Doctrine/ORM/Query/WhereWalker.php:192)
  at Knp\Component\Pager\Event\Subscriber\Filtration\Doctrine\ORM\Query\WhereWalker->primaryContainsFilter(object(ConditionalPrimary), array(object(LikeExpression)))
     (vendor/knplabs/knp-components/src/Knp/Component/Pager/Event/Subscriber/Filtration/Doctrine/ORM/Query/WhereWalker.php:158)
  at Knp\Component\Pager\Event\Subscriber\Filtration\Doctrine\ORM\Query\WhereWalker->termContainsFilter(object(ConditionalTerm), array(object(LikeExpression)))
     (vendor/knplabs/knp-components/src/Knp/Component/Pager/Event/Subscriber/Filtration/Doctrine/ORM/Query/WhereWalker.php:97)
  at Knp\Component\Pager\Event\Subscriber\Filtration\Doctrine\ORM\Query\WhereWalker->walkSelectStatement(object(SelectStatement))
     (vendor/doctrine/orm/lib/Doctrine/ORM/Query/TreeWalkerChain.php:113)
  at Doctrine\ORM\Query\TreeWalkerChain->walkSelectStatement(object(SelectStatement))
     (vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php:388)
  at Doctrine\ORM\Query\Parser->parse()
     (vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/Paginator.php:264)
  at Doctrine\ORM\Tools\Pagination\Paginator->getCountQuery()
     (vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/Paginator.php:124)
  at Doctrine\ORM\Tools\Pagination\Paginator->count()
  at count(object(Paginator))
     (vendor/knplabs/knp-components/src/Knp/Component/Pager/Event/Subscriber/Paginate/Doctrine/ORM/QuerySubscriber/UsesPaginator.php:50)
  at Knp\Component\Pager\Event\Subscriber\Paginate\Doctrine\ORM\QuerySubscriber\UsesPaginator->items(object(ItemsEvent), 'knp_pager.items', object(TraceableEventDispatcher))
     (vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php:104)
  at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(object(ItemsEvent), 'knp_pager.items', object(ContainerAwareEventDispatcher))
     (vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:212)
  at Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'knp_pager.items', object(ItemsEvent))
     (vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:44)
  at Symfony\Component\EventDispatcher\EventDispatcher->dispatch('knp_pager.items', object(ItemsEvent))
     (vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php:139)
  at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch('knp_pager.items', object(ItemsEvent))
     (vendor/knplabs/knp-components/src/Knp/Component/Pager/Paginator.php:114)
  at Knp\Component\Pager\Paginator->paginate(object(Query), 1, 20, array('pageParameterName' => 'page', 'sortFieldParameterName' => 'sort', 'sortDirectionParameterName' => 'direction', 'filterFieldParameterName' => 'filterField', 'filterValueParameterName' => 'filterValue', 'distinct' => true))
     (var/cache/dev/ContainerI7oxuiv/Paginator_f262b94.php:40)
  at Paginator_f262b94->paginate(object(Query), 1, 20)
     (src/CRMBundle/Controller/PaginationController.php:40)
  at CRMBundle\Controller\PaginationController->getPagination('CRMBundle:Lokal', 1, 20, object(Query))
     (src/CRMBundle/Controller/LokaleController.php:169)
  at CRMBundle\Controller\LokaleController->listFavoritenAction(object(Request), 'html')
     (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:151)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:68)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:200)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (web/app_dev.php:33)

Code

 $subQb = $this->createQueryBuilder('f')
            ->join('f.favoriteBy', 'ux')
            ->andWhere('ux.id  in (:userid)')
            ->andWhere("f=e");

        $qb = $this->createQueryBuilder('e');
        $qb ->join('e.address', 'a')
            ->orderBy('a.zip', 'ASC')
            ->where($qb->expr()->exists($subQb->getDQL()))
            ->setParameter('userid', $user->getId())
            ->leftJoin('e.vertreter', 'u')
            ->leftJoin('u.vertretungen', 'v')
            ->andWhere($qb->expr()->orX(
                    $qb->expr()->eq('e.vertreter', ':userid'),
                    $qb->expr()->isNull('e.vertreter'),
                    $qb->expr()->andX(
                        'v.proxy =:userid'
                    )
                ))
            ;
@nicolasmure
Copy link
Contributor

Hello :)

Do you mind to make a repo having this bug so we can easily clone it and see what's wrong ?

Also, can you describe what behavior do you expect please ;) ?

Thanks ;)

@garak
Copy link
Collaborator

garak commented Jul 23, 2019

See KnpLabs/knp-components#205

@garak garak closed this as completed Jul 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants