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

findAll(), findBy() and findOneBy() do not take care about query hints #6751

Closed
steevanb opened this issue Oct 4, 2017 · 4 comments
Closed

findAll(), findBy() and findOneBy() do not take care about query hints #6751

steevanb opened this issue Oct 4, 2017 · 4 comments

Comments

@steevanb
Copy link
Contributor

@steevanb steevanb commented Oct 4, 2017

Hi :)

When i define default hints, with this code :
$manager->getConfiguration()->setDefaultQueryHint(QueryHint::MY_HINT, true);

This methods don't pass it to EntityPersister::load() or EntityPersister::loadAll(), although load() has a parameters for that : $hints.

So, magic methods in EntityRepository could not be used, when we have default hints :(

@lcobucci
Copy link
Member

@lcobucci lcobucci commented Oct 26, 2017

@steevanb could you please send us a failing test case that reproduces that behaviour? It would help us a lot to identify and fix the issue you're describing.

You can find examples on https://github.com/doctrine/doctrine2/tree/388afb46d0cb3ed0c51332e8df0de9e942c2690b/tests/Doctrine/Tests/ORM/Functional/Ticket

@althaus
Copy link

@althaus althaus commented Aug 14, 2018

Issue is related to this PR: #863

The hints are only injected in the AbstractQuery class, but this isn't used at all by the EntityManager/EntityPersister used by the EntityRepository as it's building its SQL without the Query class.

It's just calling stuff like return $persister->load($sortedId, null, null, array(), $lockMode); where array() is the value for $hints.

@steevanb
Copy link
Contributor Author

@steevanb steevanb commented Oct 21, 2020

3 years after, i see bug is already here ;)

I've created this little repository to show you the problem:
https://github.com/steevanb/doctrine-repository-hint-bug

@beberlei
Copy link
Member

@beberlei beberlei commented Dec 6, 2020

This is expected behavior, because EntityRepository does not use DQL queries internally. I believe this is documented. the hints are not to be used for own things unless you evaluate them in an SQL Walker (See custom sql walker docs).

@beberlei beberlei closed this Dec 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants