I have just spotted that even if I select partial with id and name fields, Doctrine automatically adds all foreign keys to selected fields. How to turn it off globally or per query? I saw it when I was looking for an answer like here: Why is DoctrineExtensions Blameable eagerly fetching all created_by users.
My query looks like this:
$queryBuilder = $this->getEntityManager()->createQueryBuilder()
->select('partial c.{id, name}')
->from('MyBundle:Car', 'c')
->where('c.slug = :slug')
->setParameter('slug', $slug);
Which generates:
SELECT m0_.id AS id_0, m0_.name AS mname_1 m0_.created_by AS created_by_5, m0_.updated_by AS updated_by_6, m0_.config_id AS config_id_7, m0_.client_id AS client_id_8
FROM cars m0_
WHERE m0_.mslug = ?
["audi-a8"] []