radar/forem — Issue #159: ActionView::Template::Error (PG::Error: ERROR:  for SELECT DISTINCT, ORDER BY expressions must appear in select list
Author: gabrielbaez
Created: 2012-02-25 15:42:07+00:00
State: open

I updated to the latest forums and when I try to view a forum I'm getting a postgresql sql distinct error.

as anybody else run into this? this is on a brand new forum without any new posts.

Started GET "/forums/forums/1" for 192.168.1.252 at Sat Feb 25 09:26:05 -0600 2012
Processing by Forem::ForumsController#show as HTML
Parameters: {"id"=>"1"}
User Load (0.8ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
Forem::Forum Load (0.6ms) SELECT "forem_forums".* FROM "forem_forums" WHERE "forem_forums"."id" = $1 LIMIT 1 [["id", "1"]]
Forem::Category Load (0.3ms) SELECT "forem_categories".* FROM "forem_categories" WHERE "forem_categories"."id" = 1 LIMIT 1
CACHE (0.0ms) SELECT "forem_forums".* FROM "forem_forums" WHERE "forem_forums"."id" = $1 LIMIT 1
CACHE (0.0ms) SELECT "forem_categories".* FROM "forem_categories" WHERE "forem_categories"."id" = 1 LIMIT 1
Rendered forem/forums/_head.html.erb (7.8ms)
Forem::Topic Load (1.2ms) SELECT DISTINCT forem_topics.id, forem_topics.* FROM "forem_topics" INNER JOIN "forem_posts" ON "forem_posts"."topic_id" = "forem_topics"."id" WHERE "forem_topics"."forum_id" = 1
(0.4ms) SELECT COUNT(count_column) FROM (SELECT 1 AS count_column FROM "forem_topics" INNER JOIN "forem_posts" ON "forem_posts"."topic_id" = "forem_topics"."id" WHERE "forem_topics"."forum_id" = 1 LIMIT 20 OFFSET 0) subquery_for_count
Forem::Topic Load (0.4ms) SELECT DISTINCT forem_topics.id, forem_topics.* FROM "forem_topics" INNER JOIN "forem_posts" ON "forem_posts"."topic_id" = "forem_topics"."id" WHERE "forem_topics"."forum_id" = 1 ORDER BY forem_topics.pinned DESC, forem_posts.created_at DESC, forem_topics.id LIMIT 20 OFFSET 0
PG::Error: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list
LINE 1: ..."forum_id" = 1 ORDER BY forem_topics.pinned DESC, forem_post...
^
: SELECT DISTINCT forem_topics.id, forem_topics.* FROM "forem_topics" INNER JOIN "forem_posts" ON "forem_posts"."topic_id" = "forem_topics"."id" WHERE "forem_topics"."forum_id" = 1 ORDER BY forem_topics.pinned DESC, forem_posts.created_at DESC, forem_topics.id LIMIT 20 OFFSET 0
Rendered forem/forums/show.html.erb within layouts/application (29.9ms)
Completed 500 Internal Server Error in 185ms

ActionView::Template::Error (PG::Error: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list
LINE 1: ..."forum_id" = 1 ORDER BY forem_topics.pinned DESC, forem_post...
^
: SELECT DISTINCT forem_topics.id, forem_topics.* FROM "forem_topics" INNER JOIN "forem_posts" ON "forem_posts"."topic_id" = "forem_topics"."id" WHERE "forem_topics"."forum_id" = 1 ORDER BY forem_topics.pinned DESC, forem_posts.created_at DESC, forem_topics.id LIMIT 20 OFFSET 0):
19: <% if @topics.empty? %>
20:
<%= t('forem.topic.none') %>

21: <% end %>
22: <%= render @topics %>
23:

24:

app/views/forem/forums/show.html.erb:22:in `_app_views_forem_forums_show_html_erb__1225373306_69914620860920'

Rendered /home/gabriel/.rvm/gems/ree-1.8.7-head/gems/actionpack-3.2.1/lib/action_dispatch/middleware/templates/rescues/_trace.erb (0.9ms)
Rendered /home/gabriel/.rvm/gems/ree-1.8.7-head/gems/actionpack-3.2.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.7ms)
Rendered /home/gabriel/.rvm/gems/ree-1.8.7-head/gems/actionpack-3.2.1/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (3.6ms)