After migrating my database to CloudDB with Mysql 5.7 version I have problem with query builder in symfony 4.
The following code works great with mysql 5.6
public function findRecentReviews($max): array
{
$qb = $this->createQueryBuilder('r')
->andWhere('r.active = :active')
->setParameter('active', 1)
->setMaxResults($max)
->groupBy('r.website')
->orderBy('r.id', 'ASC')
->getQuery();
return $qb->execute();
}
With 5.7 I'm getting this error
An exception has been thrown during the rendering of a template ("An >exception occurred while executing 'SELECT r0_.id AS id_0, r0_.comment AS >comment_1, r0_.author AS author_2, r0_.email AS email_3, r0_.added AS >added_4, r0_.ip AS ip_5, r0_.active AS active_6, r0_.hide_in_latest AS >hide_in_latest_7, r0_.rate AS rate_8, r0_.website_id AS website_id_9 FROM >review r0_ WHERE r0_.active = ? GROUP BY r0_.website_id ORDER BY r0_.id ASC >LIMIT 3' with params [1]:
SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of >SELECT list is not in GROUP BY clause and contains nonaggregated column >'ps_main.r0_.id' which is not functionally dependent on columns in GROUP BY >clause; this is incompatible with sql_mode=only_full_group_by").*
I can't disable ONLY_FULL_GROUP_BY mode because I don't have a superuser privileges.
How should look like my query if I can't disable ONLY_FULL_GROUP_BY and I can't downgrade a mysql version?