#42 ✓resolved
Christian Hølmer

Joins not inferred from condition groups?

Reported by Christian Hølmer | December 22nd, 2008 @ 10:39 AM

Searchlogic is great and has really simplified some of my complex searches. One thing that bothered me though is that the main condition object infer necessary joins from conditions groups.

Given the following scenario (example from the documentation):


# Searchlogic::Version::STRING => "1.6.2"
#
# User => Orders => LineItems
# user.first_name like '%Ben%' AND (line_items.description LIKE '%cd%' OR line_items.description LIKE '%book%')

User.new_search do |s|
  s.conditions.first_name_like = "Ben"
  s.group do |group|
    group.orders.line_items.description_like = "cd" 
    group.orders.line_items.or_description_like = "book" 
  end
end

The above code fails because no joins are made with orders and then line_items.

It would work if I had just put the relationship condition directly on the search object, but then I would not get the parenthesis I want.

My temporary solution is just to declare the joins manually ("s.joins = { :orders => :line_items }"), but an automatic would be more elegant.

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Provides common named scopes and object based searching.

People watching this ticket

Pages