
or_ conditions doesn't work on associated data
Reported by Kai | February 2nd, 2009 @ 12:26 PM
I tried to find the keyword "ad" in my user.login attribute OR my user.address.company. User-hasmany addresses. For this I tried these, they all ended with and AND and not with an OR query:
s = User.new_search
s.conditions.login_keywords = "ad"
s.conditions.addresses.or_company_keywords = "ad"
s.all
User Load (0.9ms) SELECT DISTINCT users
.* FROM
users
LEFT OUTER JOIN addresses
ON
addresses.user_id = users.id WHERE
(users
.login
LIKE '%ad%' AND
addresses
.company
LIKE '%ad%') LIMIT 25
=> []
s = User.new_search
s.conditions.or_group do |group|
group.or_login_keywords = "ad"
group.addresses.or_company_keywords = "ad"
end
s.all
User Load (0.8ms) SELECT DISTINCT users
.* FROM
users
LEFT OUTER JOIN addresses
ON
addresses.user_id = users.id WHERE
((users
.login
LIKE '%ad%' AND
addresses
.company
LIKE '%ad%')) LIMIT 25
=> []
s = User.new_search
s.conditions.or_group do |group|
group.login_keywords = "ad"
group.addresses.company_keywords = "ad"
end
s.all
User Load (0.8ms) SELECT DISTINCT users
.* FROM
users
LEFT OUTER JOIN addresses
ON
addresses.user_id = users.id WHERE
((users
.login
LIKE '%ad%' AND
addresses
.company
LIKE '%ad%')) LIMIT 25
=> []
s = User.new_search
s.conditions.or_group do |group|
group.or_login_keywords = "ad"
group.addresses.or_company_keywords = "ad"
end
s.all
User Load (0.8ms) SELECT DISTINCT users
.* FROM
users
LEFT OUTER JOIN addresses
ON
addresses.user_id = users.id WHERE
((users
.login
LIKE '%ad%' AND
addresses
.company
LIKE '%ad%')) LIMIT 25
=> []
I'm pritty new to searchlogic, so help me if I'm just going in the wrong direction please.
cheers Kai
Comments and changes to this ticket
-
Ben Johnson February 2nd, 2009 @ 01:01 PM
- State changed from new to resolved
Update from the repo. This should be all fixed.
-
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.