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

Inspection: Previous QueryBuilder method call should be removed, because is overwritten here not fully correct? #1977

Closed
arneee opened this issue Jun 26, 2022 · 0 comments
Labels

Comments

@arneee
Copy link

arneee commented Jun 26, 2022

Hi,

In the Paid version a repository method like this triggers a warning:

   public function getCountOfPeople(Event $event): int {

        return intval($this->createQueryBuilder("m")
            ->select('COUNT(DISTINCT m.xyz)')
            ->where('m.event = :event')
            ->setParameter(':event', $event)
            ->getQuery()
            ->getSingleScalarResult());
    }

Warning: Symfony: Previous QueryBuilder method call should be removed, because is overwritten here

The createQueryBuilder ´from ServiceEntityRepository contains the following:

    public function createQueryBuilder($alias, $indexBy = null)
    {
        return $this->_em->createQueryBuilder()
            ->select($alias)
            ->from($this->_entityName, $alias, $indexBy);
    }

So while indeed the "select" part is overwritten, the "from" stays. Is that warning intended in this case? I feel like this would be the normal way to implement this method in a Repository extending from ServiceEntityRepository.

@arneee arneee changed the title Inspecition: revious QueryBuilder method call should be removed, because is overwritten here Inspecition: Previous QueryBuilder method call should be removed, because is overwritten here not fully correct Jun 26, 2022
@arneee arneee changed the title Inspecition: Previous QueryBuilder method call should be removed, because is overwritten here not fully correct Inspection: Previous QueryBuilder method call should be removed, because is overwritten here not fully correct? Jun 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants