gitlabhq/gitlabhq — Issue #308: Invalid SQL line
Author: rgirardRev
Created: 2012-01-19 14:04:50+00:00
State: open

I am running Mysql for this, and when accessing CommitsController#show, I was getting the following error:

ActionView::Template::Error (Mysql::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 'nu
ll)' at line 1: SELECT `notes`.* FROM `notes` WHERE `notes`.`project_id` = 23 AND `notes`.`noteable_id` = 'b7898c8df4ad1bf9db37b1e278fd3b5ae9488b1b' AND `notes`.`noteable_type` =
'Commit' AND (line_code not null)):

It appears you cannot just do "variable not null" in MySQL. It should be "variable IS not null". This should also work with SQLite.

Relavant update should be in app/models/project.rb, line 174:

notes.where(:noteable_id => commit.id, :noteable_type => "Commit").where("line_code is not null")