【问题标题】:Missing from-clause entry for table / undefined table error缺少表/未定义表错误的 from-clause 条目
【发布时间】: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"

http://pastebin.com/eNkBdkYR

【问题讨论】:

    标签: ruby-on-rails postgresql heroku pg


    【解决方案1】:

    只是在没有联合的情况下进行了查询,它可以工作! 它在早期没有工作,因为它返回的结果集看起来有些不同。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-22
      • 2019-02-17
      • 2016-03-24
      相关资源
      最近更新 更多