
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
-
Ben Johnson December 22nd, 2008 @ 12:03 PM
- State changed from new to resolved
I agree, this is done, update from the repo to get the change. Thanks!
-
-
-
Ben Johnson December 30th, 2008 @ 01:01 AM
It should because its recursive, I'll write up some tests and see if I can duplicate the problem.
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.
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.