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
ActiveRecord::QueryMethods.group() throws a MySQL error if you're grouping by an SQL keyword (in this case: key).
>> Template.group :key
!! #<ActiveRecord::StatementInvalid: Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key' at line 1: SELECT `templates`.* FROM `templates` GROUP BY key>
The problem is that the SQL statement needs backticks around the column name.
A workaround which works (but will break some operations like .count())
Template.order '`key`'
Other operations (.where(), .order(), etc.) work as expected.