【发布时间】:2014-08-24 09:35:42
【问题描述】:
这在 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"
【问题讨论】:
标签: ruby-on-rails postgresql heroku pg