所以在升級過程中從Rails的3.2項目到Rails 4.2,不知何故該查詢在我的車型之一,它看起來像:用的sql_mode不相容= only_full_group_by在MySQL
rows = ActiveRecord::Base.connection.execute("Select q.id,q.times_taken,avg(qr.correct)*100,q.difficulty,q.weight,sk.name,sa.name,sub.name,q.tag_list from
(select qu.id,qu.times_taken,qu.difficulty,qu.weight,group_concat(tags.name) tag_list,qu.subject_id,qu.subject_area_id
from questions qu left join taggings t on (qu.id = taggable_id) left join tags on (t.tag_id = tags.id)
where qu.id in (#{@questions_out_ids.join(',')}) and t.taggable_type='Question' group by t.taggable_id) q
left join subjects sub on (q.subject_id = sub.id) left join subject_areas sa on (q.subject_area_id = sa.id)
left join skills_subject_areas ssa on (sa.id = ssa.subject_area_id) left join skills sk on (ssa.skill_id = sk.id),
archived_question_results qr,attempts a where qr.question_id = q.id and a.id = qr.attempt_id and a.is_normalized = 1
and a.state = 'complete' group by qr.question_id order by q.id")
已經開始生產MySQL錯誤爲下:
ERROR 1055 (42000): Expression #6 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'faces_development.sk.name' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
我看過的類似問題的其他答案,我知道我需要包括某個表的id
列太GROUP BY
子句中,但因爲我的查詢是非常複雜的,選項我試過沒有太多用處。我正在使用寶石mysql2 0.3.0
建議?
的可能的複製[?有沒有\ _Value爲MySQL 5.6功能(http://stackoverflow.com/questions/37089347/is-there-any-value -capability-for-mysql-5-6) – e4c5