Hi Xavier
This is a known problem - ARel isn't as smart about joins as ActiveRecord 2 is,
I think. At least, that's what I'm blaming at the moment ;)
I was just about to suggest you go through the taggings association, but then
you'll lose your conditions. Can you add the special join at the taggings
level, then use that? eg:
indexes taggings.limited_tags.name, :as => :tag_list
But yeah, I think I'll need to restructure TS 2 a little to account for the
ARel behaviour.
--
Pat
On 16/01/2011, at 9:02 PM, Xavier Shay wrote:
> Hello,
> I have found a regression. The following code was working on a 2.3.5
> app with the thinking_sphinx plugin (don't know exact version but
> OLD).
>
> class Post
> has_many :taggings
> has_many :searchable_tags, :through => :taggings, :source
> => :tag, :conditions => "tags.name NOT IN ('Ruby', 'Code', 'Life')"
>
> define_index do
> indexes title
> indexes body
> indexes searchable_tags(:name), :as => :tag_list
> # indexes searchable_tags.name, :as => :tag_list # I tried this
> syntax too
> end
> end
>
> As of rails 3/latest gem, it generates the following query in my
> production.sphinx.conf:
> SELECT SQL_NO_CACHE `posts`.`id` * 1 + 0 AS `id` , `posts`.`title` AS
> `title`, `posts`.`body` AS `body`, GROUP_CONCAT(DISTINCT
> IFNULL(`tags`.`name`, '0') SEPARATOR ' ') AS `tag_list`, `posts`.`id`
> AS `sphinx_internal_id`, 4206412723 AS `class_crc`, 0 AS
> `sphinx_deleted` FROM `posts` LEFT OUTER JOIN `taggings` ON
> `posts`.`id` = `taggings`.`taggable_id` LEFT OUTER JOIN `tags` ON 0
> WHERE (`posts`.`id` >= $start AND `posts`.`id` <= $end) GROUP BY
> `posts`.`id`, `posts`.`title`, `posts`.`body`, `posts`.`id` ORDER BY
> NULL
>
> Note the "LEFT OUTER JOIN tags ON 0" is incorrect. I would expect ON
> `taggings`.`tag_id` = `tags`.`id`.
>
> Please let me know if I'm doing it wrong, or if there is more I can do
> do help fix this.
>
> Cheers,
> Xavier
>
> --
> You received this message because you are subscribed to the Google Groups
> "Thinking Sphinx" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/thinking-sphinx?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Thinking Sphinx" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/thinking-sphinx?hl=en.