Fixed duplicated join with same table performed while filtering short codes by search term and tags

This commit is contained in:
Alejandro Celaya 2018-08-04 16:15:09 +02:00
parent 110e8cb78d
commit c7239aaca2
2 changed files with 5 additions and 2 deletions

View File

@ -25,7 +25,7 @@
}
},
{
"name": "tags",
"name": "tags[]",
"in": "query",
"description": "A list of tags used to filter the resultset. Only short URLs tagged with at least one of the provided tags will be returned. (Since v1.3.0)",
"required": false,

View File

@ -93,7 +93,10 @@ class ShortUrlRepository extends EntityRepository implements ShortUrlRepositoryI
// Apply search term to every searchable field if not empty
if (! empty($searchTerm)) {
$qb->leftJoin('s.tags', 't');
// Left join with tags only if no tags were provided. In case of tags, an inner join will be done later
if (empty($tags)) {
$qb->leftJoin('s.tags', 't');
}
$conditions = [
$qb->expr()->like('s.originalUrl', ':searchPattern'),