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

Nested setFetchMode #11254

Open
gharlan opened this issue Feb 13, 2024 · 0 comments
Open

Nested setFetchMode #11254

gharlan opened this issue Feb 13, 2024 · 0 comments

Comments

@gharlan
Copy link

gharlan commented Feb 13, 2024

Feature Request

Q A
New Feature yes
RFC no
BC Break no

Summary

At the moment I'm using partial queries for fetching nested entities:

$qb = $this->createQueryBuilder('mail');
// ...
$mails = $qb->getQuery()->getResult();

$qb = $this->createQueryBuilder('mail');
$qb->select("PARTIAL mail.{id}, recipient, user");
$qb->andWhere("mail IN (:mails)")->setParameter('mails', $mails);
$qb->leftJoin('mail.recipients', 'recipient');
$qb->leftJoin('recipient.user', 'user');

Now I'm trying to convert this to setFetchMode (#8391) because partial queries are removed in v3. I've tried this:

$qb = $this->createQueryBuilder('mail');
// ...
$query = $qb->getQuery();

$query->setFetchMode(Mail::class, 'recipients', ClassMetadata::FETCH_EAGER); // this works great
$query->setFetchMode(MailRecipient::class, 'user', ClassMetadata::FETCH_EAGER); // this does not work

$mails = $query->getResult();

The second setFetchMode call does not have any effect. It would be great if setFetchMode would work for nested relations.

Or is there any other (good) replacement for my partial query?

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

1 participant