jack icon indicating copy to clipboard operation
jack copied to clipboard

Aggregated model query incompatible with MySql 5.7.5

Open tuliren opened this issue 8 years ago • 1 comments

ModelQuery#getSelectClause adds the id column to its select clause (code):

sqlClause.append("id, ");

However, when querying with a group by clause, this is incompatible with the new ONLY_FULL_GROUP_BY mode introduced in MySql 5.7.5 (reference):

Reject queries for which the select list, HAVING condition, or ORDER BY list refer to nonaggregated columns that are neither named in the GROUP BY clause nor are functionally dependent on (uniquely determined by) GROUP BY columns.

As of MySQL 5.7.5, the default SQL mode includes ONLY_FULL_GROUP_BY. (Before 5.7.5, MySQL does not detect functional dependency and ONLY_FULL_GROUP_BY is not enabled by default.

tuliren avatar Dec 12 '17 23:12 tuliren

I propose to add a @Deprecation annotation to the selectAgg method. Users can use GenericQuery instead.

tuliren avatar Dec 12 '17 23:12 tuliren