autolab / Autolab

Course management service that enables auto-graded programming assignments.
http://www.autolabproject.com/
Apache License 2.0
752 stars 214 forks source link

Manage Course breaks (rails-5-upgrade; mysql 5.7.28) #1084

Closed wallaceswsu closed 4 years ago

wallaceswsu commented 4 years ago

Pressing the "Manage Course" button in the navbar on the rails-5 branch throws an error:

     Error Information

--- !ruby/exception:ActiveRecord::StatementInvalid
message: 'Mysql2::Error: Expression #1 of ORDER BY clause is not in SELECT list, references
  column ''autolab_production.assessments.due_at'' which is not in SELECT list; this
  is incompatible with DISTINCT: SELECT DISTINCT category_name FROM `assessments`
  WHERE `assessments`.`course_id` = 4 ORDER BY due_at ASC, name ASC'

This appears to be tied to the grade book.

Although this can be solved with a change to the Autolab/config/database.yml file, it seems like a better solution would be to modify the queries involved so there are no ambiguities.

Environment:

Steps to reproduce behavior:

Working Solution:

Working Solution: (alternate)

Leads:

victorhuangwq commented 4 years ago

Hi @wallaceswsu May I know if this issue has already been fixed in the current master? If so I will proceed to close this issue.

wallaceswsu commented 4 years ago

@victorhuangwq It doesn't appear to be fixed as of 0c68d9f (which is my most recent pull from your repo -- (June 14)).

Environment

Behavior

>rake autolab:populate
Creating Course AutoPopulated and config file
Creating Assessments
Creating Problems
Fast-creating Users
Fast-creating Submissions and Scores (might take a while)
Fast-creating AUDs
rake aborted!
ActiveRecord::StatementInvalid: Mysql2::Error: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'autolab_development.submissions.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by: SELECT `submissions`.* FROM `submissions` WHERE `submissions`.`assessment_id` = 1 GROUP BY `submissions`.`course_user_datum_id` HAVING (MAX(submissions.version))
...
Caused by:
Mysql2::Error: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'autolab_development.submissions.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
Mysql2::Error: Expression #1 of ORDER BY clause is not in SELECT list, references column 'autolab_development.assessments.due_at' which is not in SELECT list; this is incompatible with DISTINCT: SELECT DISTINCT category_name FROM `assessments` WHERE `assessments`.`course_id` = 1 ORDER BY due_at ASC, name ASC 
wallaceswsu commented 4 years ago

I also verified the problem still exists in the latest master: bbfb72f

victorhuangwq commented 4 years ago

@wallaceswsu Our autolab.ml site uses MySQL for its database, and I was wondering why it does not have the issue that has mentioned. I checked the sql_mode parameters and see that the only value set is NO_ENGINE_SUBSTITUTION.

Because of this, I'm more inclined towards the alternate solution that you mentioned earlier which is to set, sql-mode = "", which by MySQL documentation, clears out the modes set. https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html

The specific queries themselves are executed by an abstraction layer in rails, which might be worth investigating in the future, but the abstraction layer is meant to help us be cross compatible with different databases as well.

I have made a patch here at https://github.com/autolab/Autolab/pull/1194. Let me know if this works for you?

victorhuangwq commented 4 years ago

If the patch works I will proceed to add the settings into the documentation as well

wallaceswsu commented 4 years ago

Thanks for the follow up! I looked into this a bit further here are a few thoughts:

Perhaps adding a comment about this (or setting NO_ENGINE_SUBSTITUTION) in the config is appropriate?

victorhuangwq commented 4 years ago

@wallaceswsu Yes, as it seems, NO_ENGINE_SUBSTITUTION was the default prior to MySQL 5.7, and it works for autolab.ml. I think it would be better to set that instead. Thank you for testing it out as well.

Edit: Updated as such in the documentation as well

fanpu commented 4 years ago

FYI: I'm not able to replicate this issue on 10.4.13-MariaDB on default configuration, so I guess there are differences between the two