graker / oc-photoalbums-plugin

Photo albums plugin for OctoberCMS
MIT License
12 stars 8 forks source link

conflict with sql_mode only_full_group_by on MySQL 5.7 #3

Closed wohenbushuang closed 7 years ago

wohenbushuang commented 7 years ago

For MySQL 5.7 the plugin conflict with default on sql_mode only_full_group_by

SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column '**.graker_photoalbums_photos.sort_order' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by (SQL: select album_id, count(*) as aggregate from graker_photoalbums_photos where graker_photoalbums_photos.album_id in (1) group by album_id order by sort_order asc) `

graker commented 7 years ago

Hi @wohenbushuang ,

I'm on vacation now and don't have means to test it right away. Could you please change this line to this:

->groupBy('album_id', 'sort_order');

and see if it works and the photos count still has correct value?

Thanks!

graker commented 7 years ago

Fixed, thanks for raising the issue.