Description
Feature Request
What
It would be nice if we could set query hints on the QueryBuilder so they are added to the new Query object when you do ->getQuery()
Why
I have some utility classes for optimising the query, for example:
- function addDistinctWhenToMany(QueryBuilder $qb): Check if we have a toMany join, if so add "$qb->distinct" and $qb->getQuery()->setHint(Query\SqlWalker::HINT_DISTINCT, true)
The reason for doing this is because blindly adding "distinct" to the query lowers performance so I only want to add it if its needed.
But if later in the process you do getQuery() again, all the previously set hints are gone because it creates a "new Query()" every time
The above is just an example, I have other use cases to set an output_walker hint if necessary and so on.
How
Adding an array to the QueryBuilder "customHints" or something like that.
And every time ->getQuery gets executed, the customHints from QueryBuilder are taken into account and added automatically