分页错误

时间:2011-05-26 04:58:57

标签: sql debugging sqlite pagination

当我尝试为Feed中的元素设置分页时出现此错误:

ActiveRecord::StatementInvalid in Videos#feed_display

Showing /rubyprograms/dreamstill/app/views/videos/feed_display.html.erb where line #6 raised:

SQLite3::SQLException: only a single result allowed for a SELECT that is part of an expression: SELECT  "timeline_events".* FROM "timeline_events" WHERE (SELECT timeline_events.* FROM timeline_events
                                       WHERE ((actor_type = 'User' AND actor_id IN (SELECT followed_id FROM relationships WHERE follower_id = 2)) AND ((secondary_subject_type = 'Video' AND subject_type <> 'Profile' AND secondary_subject_id NOT IN (SELECT id FROM videos WHERE user_id = 2)) OR (secondary_subject_type = 'User' AND secondary_subject_id <> 2) OR (secondary_subject_type = 'nil') OR (subject_type = 'Profile' AND secondary_subject_id NOT IN (SELECT id FROM videos WHERE user_id = 2) AND subject_id NOT IN (SELECT id FROM profiles WHERE user_id = 2))))
                                       ORDER BY timeline_events.created_at DESC) LIMIT 10 OFFSET 0

这是什么意思,我该如何解决?

1 个答案:

答案 0 :(得分:0)

其中一个子查询返回多个结果。这可以通过向子查询添加Distinct或限制1来修复。我会使用firefox插件“Sqlite Manager”来测试这个查询。