forked from LBRYCommunity/lbry-sdk
fixed 0 results when only filtering by lots of common tags
This commit is contained in:
parent
3afd615447
commit
de80a2ba97
1 changed files with 38 additions and 37 deletions
|
@ -432,8 +432,6 @@ def _apply_constraints_for_array_attributes(constraints, attr, cleaner, for_coun
|
|||
all_items = {item for item in all_items if item not in not_items}
|
||||
any_items = {item for item in any_items if item not in not_items}
|
||||
|
||||
if any_items:
|
||||
|
||||
any_queries = {}
|
||||
|
||||
if attr == 'tag':
|
||||
|
@ -456,13 +454,15 @@ def _apply_constraints_for_array_attributes(constraints, attr, cleaner, for_coun
|
|||
values = ', '.join(
|
||||
f':$any_common_tag{i}' for i in range(len(common_tags))
|
||||
)
|
||||
constraints[f'#_any_common_tags'] = f"""
|
||||
any_queries[f'#_any_common_tags'] = f"""
|
||||
EXISTS(
|
||||
SELECT 1 FROM tag WHERE claim.claim_hash=tag.claim_hash
|
||||
AND tag IN ({values})
|
||||
)
|
||||
"""
|
||||
|
||||
if any_items:
|
||||
|
||||
constraints.update({
|
||||
f'$any_{attr}{i}': item for i, item in enumerate(any_items)
|
||||
})
|
||||
|
@ -481,6 +481,7 @@ def _apply_constraints_for_array_attributes(constraints, attr, cleaner, for_coun
|
|||
AND {attr} IN ({values})
|
||||
)
|
||||
"""
|
||||
|
||||
if len(any_queries) == 1:
|
||||
constraints.update(any_queries)
|
||||
elif len(any_queries) > 1:
|
||||
|
|
Loading…
Reference in a new issue