开发者

Thinking sphinx sql_range_query error indexing

I have attributes for sphinx as follows.

meeting_feedback_count = <<-SQL
  SELECT    meetings.*
  FROM      meetings
  JOIN      member_meetings mm
  ON        mm.meeting_id = meetings.id
  JOIN      meeting_feedbacks mf
  ON        mf.member_meeting_id = mm.id
  GROUP BY  meetings.id
SQL

has meeting_feed开发者_如何转开发back_count,  :as => :has_feedback, :type => :boolean

I execute the sql in mysql console, it seems to work fine. But i get the error. Is there any way around this,.

sql_range_query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '*)      


The error is happening because you're inserting a full SQL query into another SQL query. You only need to use the appropriate column(s) for the field or attribute you're adding.

If the model this index is for is Meeting, then you probably want something like this:

"COUNT(meeting_feedbacks.id) > 0", :as => :has_feedback, :type => :boolean
join feedbacks

The join method forces joins on the associations that you may refer to in SQL snippets.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜