From bc870f7559304ccf995bd118cf9c76be7a910e37 Mon Sep 17 00:00:00 2001 From: Greg Roach Date: Tue, 19 Mar 2019 19:59:49 +0000 Subject: [PATCH] Fix: #2316 - same name shown twice in autocomplete --- app/Individual.php | 3 +++ app/Services/SearchService.php | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Individual.php b/app/Individual.php index 4351b91045d..ce96712898d 100644 --- a/app/Individual.php +++ b/app/Individual.php @@ -53,7 +53,10 @@ public static function rowMapper(): Closure $individual = Individual::getInstance($row->i_id, Tree::findById((int) $row->i_file), $row->i_gedcom); if ($row->n_num ?? null) { + $individual = clone $individual; $individual->setPrimaryName($row->n_num); + + return $individual; } return $individual; diff --git a/app/Services/SearchService.php b/app/Services/SearchService.php index 5bac8f92bba..d950f18bed9 100644 --- a/app/Services/SearchService.php +++ b/app/Services/SearchService.php @@ -151,8 +151,7 @@ public function searchIndividualNames(array $trees, array $search, int $offset = ->on('name.n_id', '=', 'individuals.i_id'); }) ->orderBy('n_sort') - ->select(['individuals.*', 'n_sort', 'n_num']) - ->distinct(); + ->select(['individuals.*', 'n_num']); $this->whereTrees($query, 'i_file', $trees); $this->whereSearch($query, 'n_full', $search); @@ -875,6 +874,7 @@ private function paginateQuery(Builder $query, Closure $row_mapper, Closure $row } } + return $collection; }