Created
August 22, 2012 14:42
-
-
Save mikecmpbll/3426276 to your computer and use it in GitHub Desktop.
Mysql2 error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MySQL db, Rails 3.2, Ruby 1.8.7 | |
# Works for anything other than 1 in: `students`.`sen_status_id` IN ... | |
# sens_status_id is an int column. | |
# There are significantly more rows with 1 than anything else, some are NULL, others are 2 and 3 | |
Student Load (38.5ms) SELECT DISTINCT students.* FROM `students` LEFT JOIN klasses_students ON ( klasses_students.student_id = students.id ) WHERE `students`.`sen_status_id` IN (1, 2) AND `klasses_students`.`klass_id` IN (1, 2, 3, 4, 5, 6, 7, 8, 9) AND (archived = 0) ORDER BY firstname ASC | |
Mysql2::Error: Lost connection to MySQL server during query: SELECT DISTINCT students.* FROM `students` LEFT JOIN klasses_students ON ( klasses_students.student_id = students.id ) WHERE `students`.`sen_status_id` IN (1, 2) AND `klasses_students`.`klass_id` IN (1, 2, 3, 4, 5, 6, 7, 8, 9) AND (archived = 0) ORDER BY firstname ASC | |
Completed 500 Internal Server Error in 85ms | |
ActiveRecord::StatementInvalid (Mysql2::Error: Lost connection to MySQL server during query: SELECT DISTINCT students.* FROM `students` LEFT JOIN klasses_students ON ( klasses_students.student_id = students.id ) WHERE `students`.`sen_status_id` IN (1, 2) AND `klasses_students`.`klass_id` IN (1, 2, 3, 4, 5, 6, 7, 8, 9) AND (archived = 0) ORDER BY firstname ASC): | |
app/controllers/reports_controller.rb:401:in `multiple' | |
# This on the other hand, goes through untroubled: | |
Student Load (7.7ms) SELECT DISTINCT students.* FROM `students` LEFT JOIN klasses_students ON ( klasses_students.student_id = students.id ) WHERE `students`.`sen_status_id` IN (2, 3) AND `klasses_students`.`klass_id` IN (1, 2, 3, 4, 5, 6, 7, 8, 9) AND (archived = 0) ORDER BY firstname ASC | |
# relevant bits from reports_controller.rb : | |
@students = Student.not_archived.where( conditions ).joins( joins ).select('DISTINCT students.*').order('firstname ASC') | |
line 401: @students.each do |s| |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment