Heroku的(PG ::错误:错误:列必须出现在GROUP BY子句或聚合函数中使用 [英] Heroku (PG::Error: ERROR: column must appear in the GROUP BY clause or be used in an aggregate function

查看:5221
本文介绍了Heroku的(PG ::错误:错误:列必须出现在GROUP BY子句或聚合函数中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到在Heroku这个错误,但不是本地(使用PostgreSQL在两个)。

I'm getting this error on Heroku but not locally (using PostgreSQL on both)..

错误是:

ActiveRecord::StatementInvalid (PG::Error: ERROR:  column "posts.content" must appear in the GROUP BY clause or be used in an aggregate function

我怀疑它是与这条线在我的职位型号:

I suspect it has something to do with this line in my posts model:

scope :with_tags, lambda { |tags| joins(:tags).group('posts.id').where(:tags => { :id => tags.map { |t| t.id } } ).having("COUNT(*) = ?", tags.length) }

为什么它在Heroku上只发生?如何解决呢?

why does it happen only on Heroku? how do I fix it ?

推荐答案

正如有人指出,这是在Postgres 9.0一个问题,一直定格在Postgres的9.1。在Heroku上,你可以使用 Heroku的共享的PostgreSQL插件而不是默认的数据库,这要解决这个问题。

As someone pointed out this is a problem with Postgres 9.0 that's been fixed in Postgres 9.1. In Heroku you can use the Heroku Shared PostgreSQL addon instead of the default DB and this should fix the problem.

这篇关于Heroku的(PG ::错误:错误:列必须出现在GROUP BY子句或聚合函数中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆