fix: deduplicate relationship joins when searchable_fields and facet_fields reference the same model (#217)

This commit is contained in:
d3vyce
2026-04-02 11:09:26 +02:00
committed by GitHub
parent bce71bfd42
commit 0b17c77dee
3 changed files with 76 additions and 5 deletions

View File

@@ -116,8 +116,12 @@ def _apply_joins(q: Any, joins: JoinType | None, outer_join: bool) -> Any:
def _apply_search_joins(q: Any, search_joins: list[Any]) -> Any:
"""Apply relationship-based outer joins (from search/filter_by) to a query."""
seen: set[str] = set()
for join_rel in search_joins:
q = q.outerjoin(join_rel)
key = str(join_rel)
if key not in seen:
seen.add(key)
q = q.outerjoin(join_rel)
return q