- Issue created by @hitesh-jain
- 🇮🇳India hitesh-jain
Open social PR : https://github.com/goalgorilla/open_social/pull/4296
When using the People page (admin/people) , sorting by Username triggers a SQL error when MySQL's ONLY_FULL_GROUP_BY mode is enabled. This is a common setting in modern MySQL configurations to enforce strict GROUP BY behavior, ensuring all non-aggregated fields in SELECT statements are included in the GROUP BY clause.
Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'db.profile__profile_name.profile_name_value' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
1. Go to People page i.e `admin/people` that uses the Profile Entity sort.
2. Click on "Sort" for Username field.
3. See the SQL error related to `ONLY_FULL_GROUP_BY` mode. This error happens only when the database is MySQL, as on MySQL ONLY_FULL_GROUP_BY SQL mode is enabled by default, but on MariaDB is disabled by default.
Error :
Drupal\Core\Database\DatabaseExceptionWrapper: Exception in People[user_admin_people]: SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'db.profile__profile_name.profile_name_value' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
Add the `profile_name_value` field to the `GROUP BY` clause in the `ProfileEntitySortable` class:
// Add the field to the GROUP BY clause to avoid SQL error.
$query->addGroupBy('profile__profile_name.profile_name_value');
Needs work
12.4
Code (back-end)
Open social PR : https://github.com/goalgorilla/open_social/pull/4296