gpt4 book ai didi

ruby-on-rails - Missing from-clause entry for table/undefined table 错误

转载 作者:行者123 更新时间:2023-11-29 13:59:13 33 4
gpt4 key购买 nike

这在 SQLite 中本地有效,但是当我推送到 heroku 时,我遇到了这个问题。

只有当我在 ORDER BY 中结束语句时才会出现此问题,否则不会给我带来问题。这就像它把对话分成两个对话,然后混淆了两个,我不记得这个错误发生在更早的时候——我可以发誓它是有效的。

抱歉,这太复杂了......

SELECT distinct conversations.*, receipts.is_read, profiles.nickname 
FROM conversations INNER JOIN notifications
ON notifications.conversation_id = conversations.id
INNER JOIN receipts ON receipts.notification_id = notifications.id
INNER JOIN profiles ON profiles.id = notifications.sender_id
WHERE (receipts.mailbox_type = 'inbox' AND ((receipts.receiver_id = #{self.id})))
UNION
SELECT distinct conversations.*, receipts.is_read, profiles.nickname
FROM conversations INNER JOIN notifications
ON notifications.conversation_id = conversations.id
INNER JOIN receipts ON receipts.notification_id = notifications.id
INNER JOIN profiles on profiles.id = notifications.sender_id
WHERE (receipts.mailbox_type = 'sentbox' AND ((receipts.receiver_id = #{self.id})))
ORDER BY conversations.updated_at desc

但是 Heroku 日志显示此错误。

2014-07-03T09:59:12.485350+00:00 app[web.1]: ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR:  missing FROM-clause entry for table "conversations"
2014-07-03T09:59:12.761705+00:00 app[web.1]: PG::UndefinedTable: ERROR: missing FROM-clause entry for table "conversations"

http://pastebin.com/eNkBdkYR

最佳答案

只是在没有联合的情况下进行了查询,并且有效!它之前没有工作,因为它返回的结果集因某些原因看起来不同。

关于ruby-on-rails - Missing from-clause entry for table/undefined table 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24550693/

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