gitlabhq/gitlabhq — Issue #514: Error 500 when viewing a newly created merge request
Author: diebels727
Created: 2012-03-05 22:15:08+00:00
State: open

We have recently installed Gitlab v2.2 (stable). Instead of installing with sqlite, we elected to use Postgres.

```code
Started GET "/project/merge_requests/2" for 192.168.1.10 at 2012-03-05 07:04:15 -0800
Processing by MergeRequestsController#show as HTML
Parameters: {"project_id"=>"project", "id"=>"2"}
Rendered merge_requests/_how_to_merge.html.haml (0.2ms)
Rendered commits/_commit.html.haml (3.4ms)
Rendered merge_requests/_commits.html.haml (3.8ms)
Rendered notes/_form.html.haml (2.9ms)
Rendered notes/_notes_list.html.haml (2.7ms)
Rendered notes/_notes.html.haml (8.6ms)
Rendered merge_requests/show.html.haml within layouts/project (24.7ms)
Completed 500 Internal Server Error in 61ms

ActionView::Template::Error (PG::Error: ERROR: operator does not exist: character varying = integer
LINE 1: ...otes".* FROM "notes" WHERE "notes"."noteable_id" = 2 AND "n...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
: SELECT "notes".* FROM "notes" WHERE "notes"."noteable_id" = 2 AND "notes"."noteable_type" = 'MergeRequest' ORDER BY created_at DESC LIMIT 20):
1: - @notes.each do |note|
2: - next unless note.author
3: = render :partial => "notes/show", :locals => {:note => note}
app/views/notes/_notes_list.html.haml:1:in `_app_views_notes__notes_list_html_haml__479690494_109822250'
app/views/notes/_notes.html.haml:5:in `_app_views_notes__notes_html_haml___373220228_105422760'
app/views/merge_requests/show.html.haml:66:in `_app_views_merge_requests_show_html_haml___225493959_109944550'
app/controllers/merge_requests_controller.rb:53:in `show'
```code

It looks like the error is caused by the fact that noteable_id is a varchar, and PG doesn't like this for the has_many association? This makes sense to me, but I'm curious how to go about resolving the issue.