Hi Gulli

This is a bug - or at least, an inconsistent feature. The automatic association 
scoping is only done for search calls, not search_for_ids.

I'll get this fixed when I have a chance - although a patch is certainly 
welcome :)

-- 
Pat

On 24/01/2012, at 1:39 PM, Gulli Sveinsson wrote:

> I think I found a bug so I thought I'd post here to make sure this is
> indeed incorrect. Not sure if this is a Sphinx or Thinking Sphinx
> issue.
> 
> (sphinx 2.0.2-beta, thinking-sphinx 2.0.9)
> 
> Idea.search 'tour', :with => {:thinker_id => bob.id}, :per_page =>
> 1000
> (returns 6 results... that's the number of ideas in my DB that contain
> 'tour' with bob's thinker id)
> 
> bob.ideas.search 'tour', :per_page => 1000
> (returns 6 results... the same number, which is expected since
> bob.ideas.search should do exactly the same as a search on the Idea
> model itself, with thinker_id specified in a :with hash)
> 
> Idea.search_for_ids 'tour', :with => {:thinker_id =>
> bob.id}, :per_page => 1000
> (returns 6 results... expected, search_for_ids simply returns id's and
> not full records)
> 
> bob.ideas.search_for_ids 'tour', :per_page => 1000
> (returns 280 results... this is UNexpected)
> 
> So when you invoke search_for_ids on Bob's idea collection, it doesn't
> restrict the search to only bob's ideas. Looks like search_for_ids,
> when chain invoked, does not implicitly add the :with => {:thinker_id
> => bob.id} to the search.
> 
> 
> ...BUT....
> 
> bob.ideas.search_for_ids 'tour', :with => {:thinker_id =>
> bob.id}, :per_page => 1000
> (returns 6 results)
> 
> Something strange is going on here, because the search method chained
> to bob.ideas IS limited to bob's ideas,
> but the search_for_ids method chained in the same way IS NOT limited
> to bob's ideas, unless you explicitly supply the :with restriction.
> 
> Is this intended? Seems weird.
> 
> -- 
> 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.

Reply via email to