You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MySQL 5.7.5 introduced new behaviour around its
[handling of `GROUP BY` clauses][1]. This change resulted in some
previously valid SQL queries in Release to be deemed invalid and
trigger MySQL errors including this one:
```
Error:
\#per_year#test_: #per_year should return correct data. :
ActiveRecord::StatementInvalid: Mysql2::Error: Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'release_test.deployments.created_at' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
app/models/deployment_stats.rb:18:in `per_year'
test/unit/deployment_stats_test.rb:53:in `block (2 levels) in <class:DeploymentStatsTest>'
test/unit/deployment_stats_test.rb:39:in `instance_exec'
test/unit/deployment_stats_test.rb:39:in `block in create_test_from_should_hash'
```
This change in behaviour can be reverted by setting the `sql_mode`
to `TRADITIONAL`, which is a special '[combination SQL mode][2]'
that excludes `ONLY_FULL_GROUP_BY`.
Some effort was made at first to refactor the problematic SQL queries
to avoid needing to deviate from MySQL's now-default behaviour. However,
the attempts were unsuccessful, and it is therefore more pragmatic to
follow the [convention established in Whitehall][3] to set the SQL
mode to 'traditional'.
[1]: https://dev.mysql.com/doc/refman/5.7/en/group-by-handling.html
[2]: https://dev.mysql.com/doc/refman/8.0/en/sql-mode.html#sql-mode-combo
[3]: alphagov/whitehall#6386
We have a user auth system already implemented. Use it!
The text was updated successfully, but these errors were encountered: