gpt4 book ai didi

mysql - Heroku (Postgres) 上的 Where 子句中断,但在本地运行良好 (MySQL)

转载 作者:行者123 更新时间:2023-11-29 08:55:30 28 4
gpt4 key购买 nike

我有以下代码行,在本地运行良好,但在推送到生产环境(Heroku)时会中断:

def self.find_unresolved_with_approved_client
self.joins(:client).where('clients.approved = true AND wish.status <> "Resolved"')
end

我的heroku日志中的错误如下:

2012-04-09T11:49:14+00:00 app[web.1]: ActionView::Template::Error (PGError: ERROR:  column "Resolved" does not exist
2012-04-09T11:49:14+00:00 app[web.1]: 16: %th{ :class => :span10 } Subject
2012-04-09T11:49:14+00:00 app[web.1]: 17: %th{ :class => :span4 } Status
2012-04-09T11:49:14+00:00 app[web.1]: LINE 1: ...ERE (clients.approved = true AND wishes.status != "Resolved"...
2012-04-09T11:49:14+00:00 app[web.1]: : SELECT "wishes".* FROM "wishes" INNER JOIN "clients" ON "clients"."id" = "wishes"."client_id" WHERE (clients.approved = true AND wishes.status != "Resolved") ORDER BY wishes.id LIMIT 25 OFFSET 0):

当它在本地进行文字比较时,为什么要尝试在 Production 上进行列比较?

最佳答案

您应该将查询更改为 .where('clients.approved = ? AND Wish.status != ?', true, 'Resolved')这使得适配器可以为您构建查询,这应该可以解决不同数据库的查询语法略有不同的问题

关于mysql - Heroku (Postgres) 上的 Where 子句中断,但在本地运行良好 (MySQL),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10072952/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com