search: fix multiple metatag searches not working in some cases.
Bug: in some cases searching for multiple metatags would cause one
metatag to be ignored. For example, a search for {{user:1 pool:2}} would
be treated as a search for {{pool:2}}.
Cause: we used `ActiveRecord::Relation#merge` to combine two relations,
which was wrong because `merge` doesn't combine `column IN (?)` clauses
correctly. If there are two `column IN (?)` clauses on the same column,
then `#merge` takes only the second clause and ignores the first.
Fix: write our own half-baked `#and` method to work around Rails'
broken-by-design `#merge` method.
ref: https://github.com/rails/rails/issues/33501.
This commit is contained in:
@@ -117,7 +117,7 @@ class PostQueryBuilder
|
||||
|
||||
def metatags_match(metatags, relation)
|
||||
metatags.each do |metatag|
|
||||
relation = relation.merge(metatag_matches(metatag.name, metatag.value, quoted: metatag.quoted))
|
||||
relation = relation.and(metatag_matches(metatag.name, metatag.value, quoted: metatag.quoted))
|
||||
end
|
||||
|
||||
relation
|
||||
|
||||
Reference in New Issue
Block a user