From dcb816b54811466145cb8dfc27f58c3179dcdbb3 Mon Sep 17 00:00:00 2001 From: Krzysztof Kotlarek Date: Wed, 17 Jun 2020 10:40:01 +1000 Subject: [PATCH] FIX: add table name to topic view query (#10052) When plugin is hooking into TopicView joining other tables, it may fail because `created_at` is potentially available on 2 tables. Therefore we should explicitly define which `created_at` we want. --- lib/topic_view.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/topic_view.rb b/lib/topic_view.rb index 42405f8e337..0ab7c7f060c 100644 --- a/lib/topic_view.rb +++ b/lib/topic_view.rb @@ -546,7 +546,7 @@ class TopicView columns = [:id] if !is_mega_topic? - columns << 'EXTRACT(DAYS FROM CURRENT_TIMESTAMP - created_at)::INT AS days_ago' + columns << 'EXTRACT(DAYS FROM CURRENT_TIMESTAMP - posts.created_at)::INT AS days_ago' end posts.pluck(*columns)