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

Make applyCriteria() more flexible #2503

Merged
merged 1 commit into from
Feb 22, 2015

Conversation

umpirsky
Copy link
Contributor

Here is the use case. I am creating custom repository and function to join and apply some criteria, like this:

<?php

namespace Umpirsky\Bundle\TildaBundle\Repository;

use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
use Sylius\Component\Core\Model\UserInterface;

class FooRepository extends EntityRepository
{
    public function getUsersFoos(UserInterface $user)
    {
        $queryBuilder = $this->getCollectionQueryBuilder()
            ->select($this->getAlias().', foo')
            ->join($this->getAlias().'.foo', 'foo')
        ;

        $this->applyCriteria($queryBuilder, ['foo.deleted' => false]);
        $this->applySorting($queryBuilder, ['foo.updatedAt' => 'DESC', 'foo.startTime' => 'DESC']);

        return $this->getPaginator($queryBuilder);
    }
}

I get error:

QueryException: [Syntax Error] line 0, col 130: Error: Expected end of string, got '.'  

It should be possible to do this after my fix.

pjedrzejewski pushed a commit that referenced this pull request Feb 22, 2015
@pjedrzejewski pjedrzejewski merged commit 972c665 into Sylius:master Feb 22, 2015
@pjedrzejewski
Copy link
Member

Thanks Sasha! 👍

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

Successfully merging this pull request may close these issues.

2 participants